7

I currently have installed pip 8.1.2.

So I want to upgrade it to the latest version (9.0.1) and I execute:

sudo pip install --upgrade pip


Collecting pip
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 846kB/s 
Installing collected packages: pip
  Found existing installation: pip 8.1.2
    Not uninstalling pip at /usr/lib/python2.7/dist-packages, outside environment /usr
Successfully installed pip-8.1.2
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

It seems that it correctly downloads 9.0.1 but then it refuses to uninstall the existing installation (8.1.2)

And then at the end it suggests me to upgrade using the same exact instruction I already provided!

Am I doing anything wrong?

ppasler
  • 3,579
  • 5
  • 31
  • 51
  • 1
    Are you using ubuntu http://askubuntu.com/questions/644911/unable-to-upgrade-pip ? – snakecharmerb Jan 16 '17 at 10:38
  • 1
    Try using pip from python. `python -m pip install --upgrade pip`. – Preston Hager Jan 16 '17 at 10:40
  • This link suggests using `apt`. When I do it says that 8.1.2 is the latest version. Looks like 9.0.1 is not yet available in `apt`, however using pip should upgrade. –  Jan 16 '17 at 10:41
  • Same result calling it from python `python -m pip install --upgrade pip`, downloads version 9.0.1 but then doesn't want to uninstall current version. –  Jan 16 '17 at 10:42
  • `sudo apt-get install python-pip` – ppasler Jan 16 '17 at 10:43
  • with `apt` it looks like 8.1.2 is the latest version so it doesn't upgrade. `python-pip is already the newest version (8.1.2-2ubuntu0.1).` –  Jan 16 '17 at 10:44
  • I am not sure if this is related to your problem: http://askubuntu.com/questions/486809/download-the-latest-version-of-python-pip-using-apt-get – ppasler Jan 16 '17 at 10:46
  • 1
    8.1.2 is the latest from apt, and ubuntu have modified pip to stop you overwriting it with manually installed pip. – snakecharmerb Jan 16 '17 at 10:51

3 Answers3

9

The Ubuntu pip version has been patched to prevent self-upgrades (all installation into system-managed files are prevented, the patch is named hands-off-system-packages.patch). You are supposed to use the Ubuntu packaging system to upgrade instead. The feedback provided could be improved certainly.

As there is no Ubunutu package of pip 9.0.1 available yet for your Ubuntu version, you can't actually upgrade to a newer version this way (there is a version for Zesty however).

A (ugly) work-around is to use easy_install instead:

sudo easy_install -U pip

This works because easy_install has not been booby-trapped to prevent the upgrade. However, this'll replace system managed files with the newer pip version. If your package manager were to re-install the python-pip package, it'll happily overwrite those files and you could in theory end up with a broken installation. Also, easy_install adds more files than the package would, and those extra files could cause issues later down the line, especially when you upgrade python-pip later when a new version is packaged.

If you were to use a virtualenv, you are free to upgrade pip inside that, which works just fine.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • Thanks. Actually I was about to install Jupyter, but it specifically asks to make sure you have the latest Pip version, so when trying to upgrade I found this problem. I think version 8.1.2 should be fine for jupyter. –  Jan 16 '17 at 11:41
  • Yes, that should be more that sufficient. – Martijn Pieters Jan 16 '17 at 11:41
3

If above are not working, please try this it works(I had similar situations and this works):

  1. download get-pip.py: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

  2. Run the downloaded file: python get-pip.py

    Above uninstalls the old version and install the latest ones. Reference Link: https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py

Community
  • 1
  • 1
Neo
  • 5,070
  • 10
  • 46
  • 65
  • 1
    You sir are the real Neo, may a dozen of lovely maidens find your way by tonight. After trying everything, this is the only thing that worked – Gerald Eersteling Jul 31 '18 at 08:17
1

Had a similar issue with pip not wishing to upgrade, though I'm not keen on replacing the package manager's version and as I'm always adding the --user option on installations via pip I figured "what's the harm?" in doing the same with pip on itself.

pip install --user --upgrade pip

It'll only work for one user but for some use cases that is just peachy.

S0AndS0
  • 860
  • 1
  • 7
  • 20