Reputation: 2697
when I do pip3 list
in the terminal, it comes the following error:
cliu@cliu-ubuntu:~$ pip3 list
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/list.py", line 80, in run
self.run_listing(options)
File "/usr/lib/python3/dist-packages/pip/commands/list.py", line 142, in run_listing
self.output_package_listing(installed_packages)
File "/usr/lib/python3/dist-packages/pip/commands/list.py", line 151, in output_package_listing
if dist_is_editable(dist):
File "/usr/lib/python3/dist-packages/pip/util.py", line 367, in dist_is_editable
req = FrozenRequirement.from_dist(dist, [])
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 299, in from_dist
assert len(specs) == 1 and specs[0][0] == '=='
AssertionError
Storing debug log for failure in /home/cliu/.pip/pip.log
Anyone knows how to fix this?
Upvotes: 9
Views: 3335
Reputation: 207
Though there is an accepted answer here, that did not work for me. So, my answer might help others who face the same issue. This bug was fixed with a single line commit here.
https://github.com/pypa/pip/commit/6cab71f422f2425b4d2283023c9e955f9663dde6
The solution is to change the line from
assert len(specs) == 1 and specs[0][0] == '=='
to
assert len(specs) == 1 and specs[0][0] in ["==", "==="]
The line number varies from version to version but, the debug message should make it easier to find. In your case it is line 299
, in the file "/usr/lib/python3/dist-packages/pip/__init__.py"
Upvotes: 2
Reputation: 302
I fixed this problem by commenting out the problematic assert
statement:
# assert len(specs) == 1 and specs[0][0] == '=='
This is definitely not an ideal solution, as that statement is probably there for a good reason, but pip3 list
now works, as do all the other parts of pip3 that I use.
Upvotes: 0
Reputation: 11
Strange, I have had the same problem, but the first solution didn't work for me(I was getting the same error after purging it over again and over again). So I have decided to edit the the line.
assert len(specs) == 1 and specs[0][0] == '=='
And removed:
== '=='
Funny, but it works now.
Upvotes: 0
Reputation: 30151
Judging by the bug linked in the comments, this can be fixed by upgrading to the latest Pip. Since doing that within Ubuntu/Debian's packaging system is moderately nontrivial, I think it would probably be simpler to just install a new version of Pip into a Virtualenv. Once you've created the virtualenv, you can upgrade to the latest Pip with this command:
pip install --upgrade pip
Upvotes: 4