In Python, I’m getting an error because it’s loading a module from /usr/lib/python2.6/site-packages but I’d like it to use my version in $HOME/python-modules/lib/python2.6/site-packages, which I installed using pip-python --install-option="--prefix=$HOME/python-modules --ignore-installed
How can I tell Python to use my version of the library? Setting PYTHONPATH to $HOME/python-modules/lib/python2.6/site-packages doesn’t help, since /usr/lib/... apparently has precedence.
Take a look at the site module for ways to customize your environment.
One way to accomplish this is to add a file to a location currently on
sys.pathcalledusercustomize.py, when Python is starting up it will automatically import this file, and you can use it to modifysys.path.First, set
$PYTHONPATHto$HOME(or add$HOMEif$PYTHONPATHhas a value), then create the file$HOME/usercustomize.pywith the following contents:Now when you start Python you should see your custom site-packages directory before the system default on
sys.path.