Why is PIP raising an AssertionError on pip freeze

2019-01-22 17:05发布

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?

标签: pip
7条回答
贼婆χ
2楼-- · 2019-01-22 17:51

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)

查看更多
太酷不给撩
3楼-- · 2019-01-22 17:52

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.

查看更多
4楼-- · 2019-01-22 18:00

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.

查看更多
姐就是有狂的资本
5楼-- · 2019-01-22 18:02

I found the solution at this link.

pip install setuptools==7.0

查看更多
来,给爷笑一个
6楼-- · 2019-01-22 18:06

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

查看更多
爷、活的狠高调
7楼-- · 2019-01-22 18:08

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.

查看更多
登录 后发表回答