pip install 失败(pkg_resources.find_distribution 在 req.py-prepare_files 中返回空列表)

10 投票
6 回答
9437 浏览
提问于 2025-04-18 07:46

在某个时候,我的pip安装出了问题(我怀疑是在升级到Ubuntu 14.04的时候),我尝试完全卸载后再重新安装(通过synaptic包管理器),但还是没能解决。并不是所有的包都有问题,但一些常用的包,比如autopep8和setuptools本身,就出现了问题。

我遇到的错误是

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

这个错误发生在pkg_resources.find_distribution(<看起来像是一个临时构建目录的路径>)返回了一个空列表的时候。我现在有点无从下手,所以如果有人能给点建议,我会非常感激。

6 个回答

0

这里的回答对我没有帮助(我用的是Mac OS X)。我做了这个:

 sudo easy_install --upgrade pip 

这个命令强制升级了pip,解决了“列表索引超出范围”的问题。

1

我尝试重新安装pip,但没成功。最后我按照这里的步骤重新安装了所有的python-pkg-resources,链接在这里:http://ubuntuforums.org/showthread.php?t=2167383

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

apt-get install ubuntu-desktop

现在它又能正常工作了。希望对某些人有帮助。

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

在我的ubuntu 14.04.4系统上,这个方法有效。

4

我也遇到过同样的问题,使用apt-get remove的方法对我没用。更新pip的时候不使用wheel对我有效:

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

这个命令可以解决问题:

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

撰写回答