Append to PYTHONPATH in Ubuntu
Not sure how other distros have this setup, but I know this works with Ubuntu…
First off, to view your PYTHONPATH. Load the python shell, by just running “python” from your favorite prompt. Then the following.
>>> import sys
>>> for line in sys.path: print line
Modifying it is as simple as adding a path file (such as “myproject.pth”) to this folder:
/usr/local/lib/pythonx.y/site-packages
Then within the file “myproject.pth” put the path to the folder of interest.
Important asside:
Although this is useful to know, the reason I ended up figuring this out was to add the path of my project so that my own project could access a certain folder within the project. What I really missed was just adding an __init__.py within the folder I added to my project, which is why I couldn’t treat the folder as a module… Arg!
For some reason I’m having a little tif with PYTHONPATH in .bashrc myself at the moment
michael: good advise, and I didn’t even know about the $PYTHONPATH. However, even after making the changes I still get an error “Import Error: No module named ext” – where ext is a folder under which I created _init_.py.