我发现,最近当我尝试使用pip安装Python包时,经常会得到以下错误。

我在网上找到了一个参考,一个人必须从下载目录中使用“python2 setup.py install”,并且确实发现如果我手动找到并下载包(从pypi),这将会工作。

但是,我不知道pip将包下载到哪里,和/或为什么它会以这种方式失败。

我尝试进行pip升级,但它也以类似的方式失败,出现了一堆“未知分发选项”错误(entry_points, zip_safe, test_suite, tests_require)!

皮普1.0.1 ActivePython 2.7

尝试使用ActiveState的pypm会失败,因为它们的库基数较小,而且不包括这些包。

C:\test>pip install requests-oauth
Downloading/unpacking requests-oauth
  Downloading requests-oauth-0.4.1.tar.gz
  Running setup.py egg_info for package requests-oauth
    E:\Plang\ActivePython\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'zip_safe'
      warnings.warn(msg)
    E:\Plang\ActivePython\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
      warnings.warn(msg)
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help

    error: invalid command 'egg_info'
    Complete output from command python setup.py egg_info:
    E:\Plang\ActivePython\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'zip_safe'
  warnings.warn(msg)

E:\Plang\ActivePython\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
  warnings.warn(msg)

usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: -c --help [cmd1 cmd2 ...]
   or: -c --help-commands
   or: -c cmd --help

error: invalid command 'egg_info'

当前回答

我也面临着同样的问题,我尝试了以上所有的答案。但不幸的是,上述方法都不奏效。

作为说明,我最终通过pip卸载分发解决了这个问题。

其他回答

我遇到了这个问题,以及在OS X v10.9 (Mavericks)上使用Brewed Python时的其他一些问题。

sudo pip install --upgrade setuptools

不适合我,我认为我的setuptools/分发设置是拙劣的。

我终于通过跑步让它起作用了

sudo easy_install -U setuptools

由于分发已经合并回setuptools,现在建议安装/升级setuptools:

[sudo] pip install --upgrade setuptools

以上这些在Ubuntu 12.04 LTS (Precise穿山甲)上都不适用,下面是我最终解决它的方法:

从下载setuptools下载ez_setup.py(参见“安装说明”部分),然后:

$ sudo python ez_setup.py

我希望这能帮你省点时间。

请记住,如果你已经安装了pip,你可能必须执行pip install -upgrade Distribute,并且在某些系统上(在我的系统上),你的pip可能被称为Python2的pip2。

看起来默认的easy_install在当前位置被破坏了:

$ which easy_install /usr/bin/easy_install

克服这个问题的一种方法是在站点包中使用easy_install。例如:

$ sudo python /Library/ python /2.7/site-packages/easy_install.py boto