pip: Assertion Error with pip list

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

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 42 (8 by maintainers)

Commits related to this issue

Most upvoted comments

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

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.

It happens when you install distribute using http://python-distribute.org/distribute_setup.py script. Running pip install -U distribute fixes the problem. The bug reproduces only in pip==1.4. Here’s why this line fails:

ipdb> specs
[]

I follow @arktrin 's comment and this is solved. the below is the log.

  • before
~@cherry-com(7875)$ pip list
adium-theme-ubuntu (0.3.4)
apt-xapian-index (0.45)
argparse (1.2.1)
boto (2.38.0)
bz2file (0.98)
chardet (2.3.0)
colorama (0.2.5)
command-not-found (0.3)
 ....................................
pyserial (2.6)
pysmbc (1.0.14.1)
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 348, in dist_is_editable
    req = FrozenRequirement.from_dist(dist, [])
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 236, in from_dist
    assert len(specs) == 1 and specs[0][0] == '=='
AssertionError

Storing debug log for failure in /home/cherry/.pip/pip.log

  • after
~@cherry-com(7878)$ sudo apt-get remove --auto-remove python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  python-colorama python-distlib python-html5lib python-pip
0 upgraded, 0 newly installed, 4 to remove and 207 not upgraded.
After this operation, 1,682 kB disk space will be freed.
Do you want to continue? [Y/n]
(Reading database ... 223180 files and directories currently installed.)
Removing python-pip (1.5.4-1) ...
Removing python-colorama (0.2.5-0.1ubuntu1) ...
Removing python-distlib (0.1.8-1) ...
Removing python-html5lib (0.999-2) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
~@cherry-com(7879)$ sudo easy_install pip
Searching for pip
Reading https://pypi.python.org/simple/pip/
Best match: pip 6.1.1
Downloading https://pypi.python.org/packages/source/p/pip/pip-6.1.1.tar.gz#md5=6b19e0a934d982a5a4b798e957cb6d45
Processing pip-6.1.1.tar.gz
Writing /tmp/easy_install-MTjyCd/pip-6.1.1/setup.cfg
Running pip-6.1.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-MTjyCd/pip-6.1.1/egg-dist-tmp-1x05jK
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.mailmap'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching 'pip/_vendor/Makefile'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'dev-requirements.txt'
no previously-included directories found matching '.travis'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'contrib'
no previously-included directories found matching 'tasks'
no previously-included directories found matching 'tests'
creating /usr/local/lib/python2.7/dist-packages/pip-6.1.1-py2.7.egg
Extracting pip-6.1.1-py2.7.egg to /usr/local/lib/python2.7/dist-packages
Adding pip 6.1.1 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin

Installed /usr/local/lib/python2.7/dist-packages/pip-6.1.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
~@cherry-com(7880)$ pip freeze
-bash: /usr/bin/pip: No such file or directory
~@cherry-com(7884)$ /usr/local/bin/pip freeze
/usr/local/lib/python2.7/dist-packages/pip-6.1.1-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
adium-theme-ubuntu==0.3.4
apt-xapian-index==0.45
boto==2.38.0
bz2file==0.98
chardet==2.3.0

..............................

Twisted-Web==13.2.0
unity-lens-photos==1.0
urllib3==1.7.1
Werkzeug==0.10.4
xdiagnose===3.6.3build2
zope.interface==4.0.5
~@cherry-com(7885)$