question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pip3 upgrade should not update pip binary

See original GitHub issue

Environment

  • 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:open
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
uranusjrcommented, Apr 26, 2019

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.

0reactions
msoultancommented, Apr 27, 2019

So I uninstalled all versions of pip by doing the following:

sudo apt-get remove python-pip python3-pip --yes
sudo python -m pip uninstall pip --yes
sudo python3 -m pip uninstall pip --yes

I then ran the following per the instructions on the pypi pip installation page:

$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
100 1669k  100 1669k    0     0  3436k      0 --:--:-- --:--:-- --:--:-- 3442k

Now I’ll install pip over itself an you’ll notice that whenever I install the python3 version it overwrites pip:

$ sudo python get-pip.py
Installing collected packages: pip
Successfully installed pip-19.1

$ pip --version
pip 19.1 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

$ sudo python3 get-pip.py
Installing collected packages: pip
Successfully installed pip-19.1

$ pip --version
pip 19.1 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)

$ sudo python get-pip.py
Installing collected packages: pip
Successfully installed pip-19.1

$ pip --version
pip 19.1 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

I think this effectively shows that apt is not playing any role in this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why you should upgrade pip, and how to do it - Python⇒Speed
The solution: upgrading pip. In order to get the latest and greatest packages, without compilation, you need to upgrade to a recent version...
Read more >
python - How to upgrade pip3? - Stack Overflow
sudo pip3 install --upgrade pip worked for me on amazon linux 2 but it changed the location of the binary. I updated the...
Read more >
Different Ways to Upgrade PIP Latest or Specific Version
You can upgrade the Python pip package installer to the newest(latest) available version or to a specific version using the pip command ...
Read more >
Options that control the installation process - PIP documentation
This may or may not be true of the new resolver. only-if-needed - packages are only upgraded if they are named in the...
Read more >
How To Use Pip (Simple Guide To Install, Update, Uninstall ...
If you're unsure whether you have pip installed or not, you can use the pip ... pip3 install --upgrade pip #or pip2 install...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found