How to install the latest version of pip when I already installed the provided by Ubuntu?

In Ubuntu 16.04 when you do:

pip install --upgrade pip

you get:

Collecting pip
  Using cached pip-8.1.2-py2.py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-8.1.1
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Fair enough. Now try

pip install --upgrade pip

and you get:

Collecting pip
  Using cached pip-8.1.2-py2.py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-8.1.1
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

So, how to actually get pip 8.1.2?


Its not a good idea to update the system python unless you are actually working on ubuntu code and have a specific reason to. There are a lot of system dependencies you can break by updating with pip instead of using the python libs in the APT repository.

If you are developing python applications and need to change versions of libraries then you should use either a the --user options to pip or create a virtualenv to store your users versions of the libs.

Both of these methods will gracefully fall back to using system libs if they don't have their own copies, virtualenv has more options on how to control that feedback.

pip with --user

This is as easy as just adding --user to the end of all your pip commands, this will put your python libs in ~/.local/lib/pythonX.X (where X.X is your python version number) , they will be looked for here first just be careful about doing this for root if you have to run via sudo as it may effect the system python.

virtualenv

This works in a similar way to that above but is less tied to a specific user so doesn't have the sudo limitation, you can also clone a virtualenv and upgrade it to test changes thus allowing you to revert if it sucks. http://docs.python-guide.org/en/latest/dev/virtualenvs/


It seems like this might be a problem with installing the .whl file for pip 8.1.2. A work-around to install pip 8.1.2 is to download the source directly from PyPi and install it via setup.py.

The following worked for me:

wget https://pypi.python.org/packages/e7/a8/7556133689add8d1a54c0b14aeff0acb03c64707ce100ecd53934da1aa13/pip-8.1.2.tar.gz
tar -xzvf pip-8.1.2.tar.gz
cd pip-8.1.2
sudo python setup.py install

This of course is not a solution to install pip 8.1.2 via pip install --upgrade, but should squelch the warning until this issue is resolved.