我发现,最近当我尝试使用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'

当前回答

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

sudo pip install --upgrade setuptools

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

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

sudo easy_install -U setuptools

其他回答

我只是把liquidki的回答转换成Ubuntu命令。在一个基于Ubuntu的系统上它是有效的!:

sudo apt -y install python-pip
pip install -U pip
sudo pip install -U setuptools

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

sudo pip install --upgrade setuptools

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

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

sudo easy_install -U setuptools

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

$ which easy_install /usr/bin/easy_install

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

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

对我来说,将pip从8.1.1升级到9.0.1解决了这个问题。

你可以运行sudo -H pip2 install——upgrade pip来升级你的pip版本。

安装分发,它随egg_info一起提供。

应该像pip安装分发一样简单。

从0.7版开始,Distribute已经被合并到Setuptools中。如果您使用的版本<=0.6,请使用pip install——upgrade setuptools或easy_install -U setuptools进行升级。