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

当前回答

我知道这是一个老问题,但以下是我用来在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选项安装了一些'常规'安装中缺少的依赖项。我今晚下班后会更新更多细节。

其他回答

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

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

$ sudo python ez_setup.py

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

当您试图安装pycurl时,可能会出现此错误。

在这种情况下,你应该这样做

sudo apt-get install libcurl4-gnutls-dev librtmp-dev

(创建地址:https://gist.github.com/lxneng/1031014)

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

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

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

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

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

[sudo] pip install --upgrade setuptools