On a CentOS 7 system, I have multiple versions of Python installed, each with their own version of pip:
# head -n1 /usr/local/bin/pip3.*
==> /usr/local/bin/pip3.6 <==
#!/usr/bin/python3
==> /usr/local/bin/pip3.7 <==
#!/usr/local/bin/python3.7
==> /usr/local/bin/pip3.8 <==
#!/usr/local/bin/python3.8
When I ask pip3.8 to upgrade itself, it removes the installed pip3.7:
# pip3.8 install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 19.2.3
Uninstalling pip-19.2.3:
Successfully uninstalled pip-19.2.3
Successfully installed pip-20.0.2
# head -n1 /usr/local/bin/pip3.*
==> /usr/local/bin/pip3.6 <==
#!/usr/bin/python3
==> /usr/local/bin/pip3.8 <==
#!/usr/local/bin/python3.8
Why is it doing this, and how can I prevent it?
UPDATES:
- The lib paths are different for the two installations, as shown here:
# python3.7 -c 'import sys; print(sys.path)'
['', '/usr/local/lib/python37.zip', '/usr/local/lib/python3.7', '/usr/local/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/site-packages']
# python3.8 -c 'import sys; print(sys.path)'
['', '/usr/local/lib/python38.zip', '/usr/local/lib/python3.8', '/usr/local/lib/python3.8/lib-dynload', '/usr/local/lib/python3.8/site-packages']
It is not bidirectional - upgrading
pip3.7does not removepip3.8.I believe the library gets upgraded correctly and leaves the version 3.7 library in place, it's just the shell wrapper script that's deleted. Here's after the
pip3.8upgrade:
# python3.7 -m pip --version
pip 20.0.2 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
# python3.8 -m pip --version
pip 20.0.2 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
# pip3.7 --version
bash: pip3.7: command not found
# pip3.8 --version
pip 20.0.2 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
Doing
pip3.7 install --upgrade pipdoes not remove/usr/local/bin/pip3.6, so it's not the case that it always removes previous versions.For full reproducibility, and to show that I'm starting with a fairly pristine system, here's a Gist containing my Dockerfile text: https://gist.github.com/kenahoo/a1104f9cb84694fbd5ec9d6d560a885e . It fails on the
RUN pip3.7 install setuptools numpy pandasline becausepip3.7has gone missing.It doesn't matter whether I upgrade using
python3.8 -m pip install --upgrade piporpip3.8 install --upgrade pip, both of them end up removing the/usr/local/bin/pip3.7wrapper script.