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?
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:This works because
easy_install
has not been booby-trapped to prevent the upgrade. However, this'll replace system managed files with the newerpip
version. If your package manager were to re-install thepython-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 upgradepython-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.
If above are not working, please try this it works(I had similar situations and this works):
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
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
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 viapip
I figured "what's the harm?" in doing the same withpip
on itself.It'll only work for one user but for some use cases that is just peachy.