I'm using Ubuntu 16.04 with python 2.7. I'm trying to run python from a directory other than the one given by
which pythonTo this end, I put
PYTHONPATH=$PYTHONPATH:/home/myname/pybombs/lib/python2.7/dist-packages/
into my bashrc file. Now, which python returns /usr/bin/python and echo PYTHONPATH returns :/home/myname/pybombs/lib/python2.7/dist-packages/.
Shouldn't they return the same directories?
1 Answer
From man python:
PYTHONPATH Augments the default search path for module files. The format is the same as the shell's $PATH: one or more directory path‐ names separated by colons. Non-existent directories are silently ignored. The default search path is installation dependent, but generally begins with ${prefix}/lib/python<ver‐ sion> (see PYTHONHOME above). The default search path is always appended to $PYTHONPATH. If a script argument is given, the directory containing the script is inserted in the path in front of $PYTHONPATH. The search path can be manipulated from within a Python program as the variable sys.path.The $PYTHONPATH variable just specifies additional locations from which you can import modules. It has nothing to do with the location of the Python interpreter executable that you get as output from which python.