33
21
On a Ubuntu (10.10) system, I have a Python package that installs itself into /usr/local/lib/python2.6/site-packages/
. This isn't contained in the default path (sys.path). How do I add this directory to the path?
Setting the $PYTHONPATH
environment variable is a solution, of course, but I'm looking for a more elegant way to do this. For example easy_install
also puts installed packages in it, my sys.path looks something like this:
['', '/usr/local/lib/python2.6/dist-packages/keyring-0.5.1-py2.6.egg',
'/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk',
'/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload',
'/usr/local/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages',
'/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/pymodules/python2.6',
'/usr/lib/pymodules/python2.6/gtk-2.0']
so the path is obviously not the default built into the Python binary.
Is there a single config file that contains the entries above? Or in what ways is it possible to modify it?
1thanks, works perfectly :) (I ended up adding a .pth file to /usr/local/python2.6/dist-packages, containing "../site-packages") – Latanius – 2011-02-18T21:40:37.633
1You can also create a module called
sitecustomize.py
whichsite.py
tries to import and modifysys.path
there. – TestUser16418 – 2011-02-18T22:11:24.130