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.
python -m pip uninstall [options] <package> ... python -m pip uninstall [options] -r <requirements file> ... Uninstall packages. pip is able to uninstall most installed packages. Known exceptions are: Pure distutils packages installed with python setup.py install, which leave behind no metadata to determine what files were installed.
There are two ways to install Python packages: Using a requirements.txt file that defines the required packages and their version numbers. But before we start, let’s make sure pip itself is installed! Good news; chances are that Pip is already present on your system. Most Python installers also install Pip.
On a Mac, Python 2.7 is installed by default, but pip is not included. If you install Python with Homebrew, the pip will be installed at the same time. In Anaconda, conda is used for package management instead of pip.
You are using pip version 18.0, however version 18.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. As the message says, you can update the pip itself with the following command. For the pip2 and pip3 commands, only the first pip should be replaced with pip2 or pip3.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With