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?
The meaning of an AssertionError is that something happened that the developer thought was impossible to happen. So if an AssertionError is ever thrown, it is a clear sign of a programming error.
In Python, assert is a simple statement with the following syntax: assert expression[, assertion_message] Here, expression can be any valid Python expression or object, which is then tested for truthiness. If expression is false, then the statement throws an AssertionError .
The assert Statement When it encounters an assert statement, Python evaluates the accompanying expression, which is hopefully true. If the expression is false, Python raises an AssertionError exception.
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
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With