Python: Referencing another project

command linepython

I want to be able to run my Python project from the command line. I am referencing other projects, so I need to be able run modules in other folders.

One method of making this work would be to modify the Pythonpath environment variable, but I think this is an abuse. Another hack would be to copy all the files I want into a single directory and then run Python. Is there a better method of doing this?

Note: I am actually programming in Eclipse, but I want to be able to run the program remotely.

Similar questions:

Best Answer

If you import sys, it contains a list of the directories in PYTHONPATH as sys.path

Adding directories to this list (sys.path.append("my/path")) allows you to import from those locations in the current module as normal without changing the global settings on your system.