Environment: debian 4.0
Python 2.4
My 'project' is installed in:
/usr/lib/python2.4/site-packages/project.
But I want to use my working copy instead of the installed one which is located in:
/home/me/dev/project/src
So what I do is:
export PYTHONPATH=/home/me/dev/project/src
ipython
import foo # which is in src
foo.__file__
*/usr/lib/python2.4/site-packages/project/foo.py*
instead of :
/home/me/dev/project/src/project/foo.py
How come? I try to check the pathes (having done the export above) and what I see is:
import sys,os
sys.path
['',
'/usr/bin',
'/usr/lib/python2.4/site-packages',
'/home/me/dev/project/src',
'/usr/lib/python24.zip',
'/usr/lib/python2.4',
'/usr/lib/python2.4/plat-linux2',
'/usr/lib/python2.4/lib-tk',
'/usr/lib/python2.4/lib-dynload',
'/usr/local/lib/python2.4/site-packages',
'/usr/lib/python2.4/site-packages/PIL',
'/var/lib/python-support/python2.4',
'/usr/lib/python2.4/site-packages/IPython/Extensions',
'/home/me/.ipython']os.environ['PYTHONPATH']
/home/me/dev/project/src
Best Answer
According to python documentation, this is expected behavior: https://docs.python.org/2.4/lib/module-sys.html:
Under python-2.6 it is different: http://docs.python.org/tutorial/modules.html#the-module-search-path