Reputation: 332
I am managing several modules on an HPC, and want to install some requirements for a tool using pip.
I won't use virtualenv because they don't work well with our module system. I want to install module-local versions of packages and will set PYTHONPATH
correctly when the module is loaded, and this has worked just fine when the packages I am installing are not also installed in the default python environment.
What I do not want to do is uninstall the default python's versions of packages while I am installing module-local versions.
For example, one package requires numpy==1.6
, and the default version installed with the python I am using is 1.8.0
. When I
pip install --install-option="--prefix=$RE_PYTHON" numpy==1.6
where RE_PYTHON
points to the top of the module-local site-packages directory, numpy==1.6
installs fine, then pip goes ahead and starts uninstalling 1.8.0
from the tree of the python I am using (why it wants to uninstall a newer version is beyond me but I want to avoid this even when I am doing a local install of e.g. numpy==1.10.1
).
How can I prevent pip from doing that? It is really annoying and I have not been able to find a solution that doesn't involve virtualenv.
Upvotes: 18
Views: 11667
Reputation: 102039
You have to explicitly tell pip
to ignore the current installed package by specifying the -I
option (or --ignore-installed
). So you should use:
PYTHONUSERBASE=$RE_PYTHON pip install -I --user numpy==1.6
This is mentioned in this answer by Ian Bicking.
Upvotes: 20