39

My console:

desarrollador@desarrollador-HP-14-Notebook-PC1:~$ pip freeze  
Exception:  
Traceback (most recent call last):  
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 126, in main  
    self.run(options, args)  
  File "/usr/lib/python2.7/dist-packages/pip/commands/freeze.py", line 68, in run  
   req = pip.FrozenRequirement.from_dist(dist, dependency_links, find_tags=find_tags)  
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 156, in from_dist  
    assert len(specs) == 1 and specs[0][0] == '=='  
AssertionError

I installed the tornado package and this happened since. How can I fix it?

BMW
  • 42,880
  • 12
  • 99
  • 116
Luis Masuelli
  • 12,079
  • 10
  • 49
  • 87
  • you are providing very little information. What version of pip are you using? Did you have a look at the various threads here at SO with the same or similar error message? It might be related to `distribute`. Do you happen to still have a version of `distribute` installed? – cel Dec 30 '14 at 23:26
  • 1
    there's no thread like this in SO. I'm using the most recent version. – Luis Masuelli Dec 31 '14 at 01:51
  • I'm getting this, too. I'm using pip version 1.5.4. `pip install` works just fine. – Luke Yeager Jan 08 '15 at 21:00
  • `sudo easy_install -U pip` would fix it. – Pavan Gupta Oct 12 '15 at 06:37

7 Answers7

37

This worked for me (running Ubuntu, both 12 and 14 LTS):

pip install -U setuptools
pip install -U pip

Upgrade to the latest version of setuptools in order to be able to upgrade to the latest version of pip, and upgrade to the latest version of pip to get a version that has fixed the AssertException error.

knickum
  • 581
  • 1
  • 5
  • 8
18

Reason: The python-pip package in Ubuntu 12.04 is seriously outdated and has some bugs with certain package names (as I can see) and cannot parse them correctly.

Solution: install a newer version of pip, via easy_install.

Luis Masuelli
  • 12,079
  • 10
  • 49
  • 87
  • 1
    I just realized i have several versions of pip on my $PATH ! the first pip on the path was the older version. run each of the pip's with pip -V to check which one is the latest (today: 7.1.2) and remove the old ones. – Berry Tsakala Dec 31 '15 at 13:57
  • ended up deleting / removing / purging all the 'pip's i had, and then installing the latest. i guess it's because there are 5 different ways to install pip, and each one does it a little bit differently. – Berry Tsakala Dec 31 '15 at 14:15
15

Your pip may be outdated. Even in Ubuntu 14.04 LTS, the pip version it installed using apt-get install python-pip was 1.5.4. Try updating pip manually, and possibly the new packages again as well.

pip --version # 1.5.4
curl -O https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
pip --version # 6.0.8
hash -r # reset bash cache

https://pip.pypa.io/en/latest/installing.html

wisbucky
  • 33,218
  • 10
  • 150
  • 101
8

I found the solution at this link.

pip install setuptools==7.0

Luke Yeager
  • 1,400
  • 1
  • 17
  • 30
  • 1
    Try running `pip list`. If your problem is similar to mine, pip will list most of the packages before throwing an error on the package that's creating the problem. Then take a look at `/usr/local/lib/python2.7/dist-packages/` (or wherever your packages are installed) and see if you can figure out what the next package is alphabetically. Maybe that will get you the information you need to solve it? – Luke Yeager Jan 08 '15 at 21:36
  • I could manage to upgrade pip! :D I was using pip 1.0 (the one that comes with ubuntu 12.04) – Luis Masuelli Jan 08 '15 at 21:38
  • This did work for me temorarily, but installing other packages I install update setup tools so downgrading does not appear to be an option for me. – ThorSummoner Dec 15 '15 at 22:38
3

First, I ran Martin Mohan's solution:

/usr/local/bin/pip uninstall pip
apt-get remove python-pip
apt-get install python-pip

Then, boredcoding's ultimately fixed the problem, both solutions are found near bottom of thread: I screwed up the system version of Python Pip on Ubuntu 12.10

$apt-get install python-pip
$which pip
/usr/bin/pip

$pip install -U pip
$which pip
/usr/bin/pip

$hash -r
$which pip
/usr/local/bin/pip

The logic behind these two fix are stated in the thread (linked above), so I will refrain from going into each here.

Community
  • 1
  • 1
Jacob Irwin
  • 153
  • 1
  • 13
3

The problem is due to an old version of pip being installed. Run the following command to install a new version of pip:

sudo easy_install -U pip. 
Michael
  • 1,453
  • 3
  • 20
  • 28
2

It may be a bit late, but one thing I found was there are 2 or three versions of pip installed (depending on what you installed)

pip - the OS version installed, freeze doesn't work and it can be out of date pip2 - the newer one installed but upgrading pip via pip etc pip3 - installed if you have python3 and python2 installed at the same time.

You can either change which pip gets used in $PATH, or do what I did:

pip2 freeze (which does work on ubuntu14 if you have more than one option for python)

MisterG
  • 21
  • 1