pip3 upgrade should not update pip binary
See original GitHub issueEnvironment
- pip version: 19.1
- Python version: 2 and 3
- OS: Ubuntu
Description If you install pip (i.e. sudo apt-get install python-pip) you get pip for Python 2.x. If you install pip3 (i.e. sudo apt-get install pip) you get pip3 for Python 3.x. If you run sudo pip3 install pip —update it will update pip3, but it will also update the pip binary and now running pip to install a package will install the package for Python 3.x, not 2.x
Expected behavior
I think there’s a pretty long-running convention that python -> 2.x and python3 -> 3.x - for that same reason, the convention should hold with pip -> python 2.x and pip3 -> python 3.x - doing otherwise is just confusing. I get that we’re trying to get users to migrate away from python 2.x, but there are plenty of people that still (and still will) use python 2.x and have historically been using pip to install python 2.x packages.
How to Reproduce
Running the pip3 upgrade breaks pip:
$ sudo python3 -m pip install pip --upgrade --force-reinstall
Installing collected packages: pip
Found existing installation: pip 19.1
Uninstalling pip-19.1:
Successfully uninstalled pip-19.1
Successfully installed pip-19.1
$ pip --version
pip 19.1 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)
$ pip3 --version
pip 19.1 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)
Forcing the pip (pip2) upgrade re-associates pip with python 2.x:
$ sudo python -m pip install pip --upgrade --force-reinstall
Installing collected packages: pip
Found existing installation: pip 19.1
Uninstalling pip-19.1:
Successfully uninstalled pip-19.1
Successfully installed pip-19.1
$ pip --version
pip 19.1 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
$ pip3 --version
pip 19.1 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
The Debian packager is responsible to “fix” this IMO. Either by doing the thing you say, or (better IMO) disabling pip self update outright. It makes zero sense to
sudo pip install -U pip
on a pip installed by apt, almost guaranteed to be a user mistake.So I uninstalled all versions of pip by doing the following:
I then ran the following per the instructions on the pypi pip installation page:
Now I’ll install pip over itself an you’ll notice that whenever I install the python3 version it overwrites pip:
I think this effectively shows that apt is not playing any role in this issue.