pip install broken (pkg_resources.find_distributio

2020-02-25 11:36发布

问题:

At some point my pip installation broke (I suspect when upgrading to Ubuntu 14.04) and I haven't been able to unbreak it by completely removing it and reinstalling (via synaptic package manager). It doesn't occur for all packages but for a few common ones such as autopep8 and even setuptools itself.

The error I am getting is

Downloading from URL https://pypi.python.org/packages/3.3/p/pep8/pep8-1.5.6-py2.py3-none-any.whl#md5=c7da9fb6a4316b53b6a873de076441e2 (from https://pypi.python.org/simple/pep8/)
Cleaning up...
  Removing temporary dir /tmp/pip_build_tclose...
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/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1259, in prepare_files
    )[0]
IndexError: list index out of range

which occurs when pkg_resources.find_distribution(<what-appears-to-be-a-temp-build-directory-for-package-to-install>) returns an empty list. I am kind of out of ideas so any pointers would be most appreciated.

回答1:

This fixes the problem:

pip install --no-use-wheel --upgrade distribute



回答2:

Had the same problem and the apt-get remove solution didn't work for me. Updating pip without wheel worked for me:

sudo pip install -U --no-use-wheel pip


回答3:

sudo pip install --no-use-wheel scikit-image

This works for me on ubuntu 14.04.4



回答4:

I tried to reinstall pip and that didn't work but eventually resinstalled all of python-pkg-resources following the directions here http://ubuntuforums.org/showthread.php?t=2167383,

apt-get remove --purge python-pkg-resources

apt-get install ubuntu-desktop

and it is now working again. Hope someone finds this useful.



回答5:

None of the answers provided here helped me (Mac OS X). I did this instead:

 sudo easy_install --upgrade pip 

which force upgraded pip and fixed the problem with 'list index out of range'.



回答6:

Before answers does not work for me, So I do a complete reinstallation and it works in ubuntu 14.04.4

sudo pip install -U pip