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?

4
  • 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
    Commented Dec 30, 2014 at 23:26
  • 1
    there's no thread like this in SO. I'm using the most recent version. Commented Dec 31, 2014 at 1:51
  • I'm getting this, too. I'm using pip version 1.5.4. pip install works just fine. Commented Jan 8, 2015 at 21:00
  • sudo easy_install -U pip would fix it. Commented Oct 12, 2015 at 6:37

7 Answers 7

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.

1
  • 1
    sometimes you have add sudo if root had installed pip
    – gokul_uf
    Commented Mar 22, 2016 at 17:41
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.

2
  • 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. Commented Dec 31, 2015 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. Commented Dec 31, 2015 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

0
8

I found the solution at this link.

pip install setuptools==7.0

3
  • 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? Commented Jan 8, 2015 at 21:36
  • I could manage to upgrade pip! :D I was using pip 1.0 (the one that comes with ubuntu 12.04) Commented Jan 8, 2015 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. Commented Dec 15, 2015 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.

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. 
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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.