Configuring System PYTHONPATH

Don Taylor
  • Don Taylor

    Don Taylor - 2006-12-15

    I am having trouble getting Pydev to see a  module in an import statement.  I must be doing something stupid, but I can't figure it out.

    I have .pth file in my C:\Python24 folder that contains:


    When I configure an interpreter I see both of these folders as candidates for the System PYTHONPATH and I check them both.

    When I import something from D:\pythoncommon then Pydev accepts it ok, but when I try to import something from D:\pythoncommon\pydispatch then Pydev gives me an unresolved import error.

    When I F9 run the code it works - so the import is being resolved correctly at run-time.

    I have tried this with and without PYTHONPATH environment variables, I have run Eclipse -clean and I have removed and re-istalled the Python interpreter.  Many times for all of these things!


    • Don Taylor

      Don Taylor - 2006-12-15

      Upon further investigation it seems to be something to do with having my package in a lower-level folder.

      I moved the contents of D:\pythoncommon\pydispatch to a new top-level folder D:\pydispatch, adjusted the .pth file, cleaned eclipse, re-installed the Python interpreter and now my import statement works as expected.

      I don't really want to clutter up my top-level folder structure like this, so I would still like to know if there is a better solution.

      TIA.  Don.

    • Fabio Zadrozny

      Fabio Zadrozny - 2006-12-15

      You should add neither to your system pythonpath.

      You should only add the D:\pythoncommon\pydispatch to your project pythonpath. That's a thing with python... you can not have one source inside of the other (because it will go for the one it resolves first).



      • Don Taylor

        Don Taylor - 2006-12-15

        Doh!  I forgot all about the project PYTHONPATH.




Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks