Python – pip upgrade messed up python installation

pippython

I'm trying to install a python application I wrote on a freshly created Ubuntu 16.4 virtual instance. I need to install a number of python packages that I previously installed on my own PC.

Everything was going along swimmingly, until I saw this message:

You are using pip version 8.1.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Okay, thinks I, this looks harmless enough.

However, after doing this, the next time I run pip, I get:

$ pip freeze
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main

I thought I should revert to the old pip so

$ sudo apt install python-pip

and then

$ sudo apt install python-pip
...
Setting up python-pip (8.1.1-2ubuntu0.4) ...

OK, I've got pip 8.1.1 back. But alas

$ pip freeze
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main

So the question is what got screwed up by the upgrade of pip and how do I fix it?

Best Answer

 $python -m pip uninstall pip

Use this and it will give you the previous pip version.

Related Question