我发现,最近当我尝试使用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 install setuptools==28.8.0

其他回答

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

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

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

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

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

我知道这是一个老问题,但以下是我用来在Windows 7 / Python2上实际安装cassandra-driver的步骤。我有windows10 / Python3在家里,我今晚将测试这个。我已经确认这也适用于Windows 10的Python 2和3。

问题

Command "python setup.py egg_info" failed with error code 1 in c:\users\Frito\appdata\local\temp\pip-build-7dgmdc\cassandra-driver

TL;博士的解决方案

已安装https://www.microsoft.com/en-us/download/details.aspx?id=44266 (Microsoft Visual c++ Compiler for Python 2.7)

解决方案(我希望有人能解释为什么这样做)

尝试pip安装cassandra-driver,并得到上述错误消息 尝试pip install——pre cassandra-driver,得到以下错误

distutils.errors.DistutilsError: Setup script exited with error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27 Command "c:\users\Frito\.virtualenvs\symdash\scripts\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\Frito\\appdata\\local\\temp\\pip-build-sesxxu\\cassandra-driver\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\Frito\appdata\local\temp\pip-ujsxsk-record\install-record.txt --single-version-externally-managed --compile --install-headers c:\users\Frito\.virtualenvs\symdash\include\site\python2.7\cassandra-driver" failed with error code 1 in c:\users\Frito\appdata\local\temp\pip-build-sesxxu\cassandra-driver

安装Microsoft Visual c++编译器for Python 2.7 成功执行pip install——pre cassandra-driver 成功执行pip uninstall cassandra-driver 成功执行pip install cassandra-driver

重申一下,我真的不确定为什么这样做有效。现在我的两个主要结论是,要么是c++编译器是必需的,要么是第一次运行——pre选项安装了一些'常规'安装中缺少的依赖项。我今晚下班后会更新更多细节。

pip install -U setuptools and easy_install将egg-info放在错误的目录下。

然后我重新安装了apt-get install python-dev。 之后让我安装我想要的驱动程序

在CentOS 6.5上,干净安装的简短回答是:

Yum -y安装python-pip pip install -U pip pip install -U setuptools pip install -U setuptools

你没有看到两次,你必须运行setuptools升级两次。答案如下:

使用yum安装python-pip包会带来python-setuptools作为依赖项。这是一个相当旧的版本,因此它实际上安装的是发行版(0.6.10)。安装包管理器后,我们通常想要更新它,所以我们执行pip install -U pip。对我来说,pip的当前版本是1.5.6。

现在我们去更新setuptools,这个版本的pip足够聪明,它知道它应该首先删除旧版本的distribute。它会这样做,但随后不会安装最新版本的setuptools,而是安装setuptools (0.6c11)。

在这一点上,由于这个非常旧的setuptools版本,所有的东西都被破坏了,但我们实际上已经成功了一半。如果我们现在再次运行完全相同的命令,pip install -U setuptools,旧版本的setuptools将被删除,并安装5.5.1版本。我不知道为什么pip没有把我们直接带到新版本,但这就是正在发生的事情,希望它能帮助其他人看到这一点,并知道你没有疯掉。