19

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?

12
  • Does sudo -H pip install --upgrade pip work?
    – edwinksl
    Commented May 22, 2016 at 19:41
  • @edwinksl: it gives the same results as the other commands.
    – user2413
    Commented May 22, 2016 at 20:13
  • That seems strange since it worked for me. Probably need to file a bug report.
    – edwinksl
    Commented May 22, 2016 at 20:15
  • @edwinksl: thanks. I'll wait a couple of days more and do that>
    – user2413
    Commented May 22, 2016 at 20:17
  • 1
    @edwinksl Just opened an issue in case anyone wants to track it. Commented Jun 4, 2016 at 5:42

4 Answers 4

13
+50

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/

2
  • 1
    You really want to do an alt install of python if you want 2.7, so you won't interfere with the OS python. From there, you need to update pip in the alt install before the venv. You also want --no-cache-dir to prevent the cached version from being installed.
    – Wyrmwood
    Commented Jun 7, 2016 at 16:08
  • Updating pip does not negatively impact (in anyway) python 2.7 which is by default shipped.
    – Afflicted
    Commented Oct 9, 2017 at 23:30
10

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.

1
  • There is a comment on that thread that suggests that this partly related to ubuntu patching their packaged version of pip to stop it upgrading apt installed packages.
    – Amias
    Commented Jun 6, 2016 at 10:13
5

sudo -H python -m pip install --upgrade pip will solve your issue. As someone mentioned above though the system specific requires python 2.7 for certain things... That being said you can upgrade pip without negatively impacting that but you can also install 3.5 alongside if you want to.

the -H is a flag for sudo that requests that the security policy set the HOME environment variable to the home directory specified by the target user's password database entry. Depending on the policy, this may be the default behavior.

2
  • If someone wants to downvote a thought out post like this you should really say why This is poor form. Commented Jun 27, 2017 at 19:23
  • Because they're angry and need to vent there anger on someone. Angry at what you ask, life in general. stack overflow has turned into nothing but a place to come and be harassed in.
    – Afflicted
    Commented Jun 27, 2017 at 19:24
2

Uninstall pip using apt-get and install it using easy_install. It worked for me.

sudo apt-get remove python-pip
sudo easy_install pip
1
  • easy_install fails. I get bash: /usr/bin/pip: No such file or directory. And I can't purge pip now either. I hope this hasn't completely broken pip on my machine. Commented Mar 21, 2019 at 15:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .