question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assertion Error with pip list

See original GitHub issue

I experienced the following error after installing pip and attempting a: pip list --outdated


C:\Python33\Scripts\pip-script.py run on 07/27/13 15:32:54
Exception:
Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\pip\basecommand.py", line 134, in main
    status = self.run(options, args)
  File "C:\Python33\lib\site-packages\pip\commands\list.py", line 74, in run
    self.run_outdated(options)
  File "C:\Python33\lib\site-packages\pip\commands\list.py", line 83, in run_outdated
    for dist, remote_version_raw, remote_version_parsed in self.find_packages_latests_versions(options):
  File "C:\Python33\lib\site-packages\pip\commands\list.py", line 104, in find_packages_latests_versions
    installed_packages = get_installed_distributions(local_only=options.local, include_editables=False, skip=self.skip)
  File "C:\Python33\lib\site-packages\pip\util.py", line 384, in get_installed_distributions
    return [d for d in pkg_resources.working_set
  File "C:\Python33\lib\site-packages\pip\util.py", line 387, in <listcomp>
    and editable_test(d)
  File "C:\Python33\lib\site-packages\pip\util.py", line 377, in <lambda>
    editable_test = lambda d: not dist_is_editable(d)
  File "C:\Python33\lib\site-packages\pip\util.py", line 347, in dist_is_editable
    req = FrozenRequirement.from_dist(dist, [])
  File "C:\Python33\lib\site-packages\pip\__init__.py", line 194, in from_dist
    assert len(specs) == 1 and specs[0][0] == '=='
AssertionError

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:42 (8 by maintainers)

github_iconTop GitHub Comments

15reactions
UzLAcommented, Apr 9, 2016

The issue is still there in Ubuntu 15.04, pip 1.5.6, distribute-0.7.3 (the pip upgrade of ‘pip’ or ‘distribute’ does not work, as the issue seems to be Ubuntu specific. See below).

The fix it:

  • to remove ubuntu package: sudo apt-get remove --auto-remove python-pip
  • download official pip installer: wget https://bootstrap.pypa.io/get-pip.py
  • install pip by running downloaded installer: sudo python get-pip.py
  • add sym-link to make it run without full path: sudo ln -s /usr/local/bin/pip /usr/bin/pip

Done!


The issue logs:

$ sudo pip install -U pip
Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-6.1.1-py2.py3-none-any.whl#md5=172eb5abab25a5e0f7a7b63c7a49378d
  Downloading pip-6.1.1-py2.py3-none-any.whl (1.1MB): 1.1MB downloaded
Installing collected packages: pip
  Found existing installation: pip 1.5.6
    Not uninstalling pip at /usr/lib/python2.7/dist-packages, owned by OS
Successfully installed pip
Cleaning up...

$ pip install --upgrade distribute
Downloading/unpacking distribute
  Downloading distribute-0.7.3.zip (145kB): 145kB downloaded
  Running setup.py (path:/tmp/pip-build-ZpdlMd/distribute/setup.py) egg_info for package distribute

Downloading/unpacking setuptools>=0.7 (from distribute)
  Downloading setuptools-16.0-py2.py3-none-any.whl (461kB): 461kB downloaded
Installing collected packages: setuptools, distribute
  Running setup.py install for distribute

Successfully installed setuptools distribute
Cleaning up...

$ pip list
aniso8601 (0.92)
...
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/list.py", line 80, in run
    self.run_listing(options)
  File "/usr/lib/python2.7/dist-packages/pip/commands/list.py", line 142, in run_listing
    self.output_package_listing(installed_packages)
  File "/usr/lib/python2.7/dist-packages/pip/commands/list.py", line 151, in output_package_listing
    if dist_is_editable(dist):
  File "/usr/lib/python2.7/dist-packages/pip/util.py", line 367, in dist_is_editable
    req = FrozenRequirement.from_dist(dist, [])
  File "/usr/lib/python2.7/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/user/.pip/pip.log
7reactions
arktrincommented, Dec 21, 2014

I’ve installed pip with sudo apt-get install python-pip, but even with latest pip, distribute and setuptools I still had AssertionError when using pip list or pip freeze in Ubuntu 14.10. Command sudo apt-get install python-pip also installs dependencies: python-colorama, python-distlib, python-html5lib, python-requests and python-wheel . I think some of these modules are giving me AssertionError, so I’ve uninstalled pip with all dependencies with sudo apt-get remove --auto-remove python-pip, and then just pip with sudo easy_install pip. Only this way works for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pip list crashes with an AssertionError - python - Stack Overflow
The problem, as I understand it, is that pip as provided by Ubuntu is old, and also cannot update itself (since it's managed...
Read more >
Fixing an assertion error on pip list
The blog post describes how to fix an assertion error when trying to list Python packages with the 'pip list' command.
Read more >
Python | Assertion Error - GeeksforGeeks
Assertion is a programming concept used while writing a code where the user declares a condition to be true using assert statement prior...
Read more >
Changelog - pip documentation v22.3.1
This fixes an AssertionError that occurred when determining installation order, for a very specific combination of upgrading-already-installed-package + ...
Read more >
Python's assert: Debug and Test Your Code Like a Pro
If the condition of an assert statement evaluates to false, then assert raises an AssertionError . If you provide the optional assertion message ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found