问题:Python pip安装失败:无效的命令egg_info

我最近经常尝试使用pip安装Python软件包时发现这一点收到以下错误。

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

但是,我不知道pip将软件包下载到何处,和/或为什么这种方式会失败。

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

尝试使用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'

I find that recently often when I try to install a Python package using pip, I get the error(s) below.

I found a reference online that one has to use “python2 setup.py install” from the download directory, and indeed find that this will then work if I manually find and download the package (from pypi).

But, I don’t know where pip is downloading packages to, and/or why it is failing in this manner.

I tried to do a pip upgrade, but it also failed in a similar manner, with a bunch of “Unknown distribution option” errors (entry_points, zip_safe, test_suite, tests_require)!

Trying to use ActiveState’s pypm fails, because they have a smaller library base, and it doesn’t include these packages.

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'

回答 0

安装分发附带的egg_info

应该很简单pip install Distribute

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

Install distribute, which comes with egg_info.

Should be as simple as pip install Distribute.

Distribute has been merged into Setuptools as of version 0.7. If you are using a version <=0.6, upgrade using pip install --upgrade setuptools or easy_install -U setuptools.


回答 1

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

[sudo] pip install --upgrade setuptools

As distribute has been merged back into setuptools, it is now recommended to install/upgrade setuptools instead:

[sudo] pip install --upgrade setuptools

回答 2

请记住,pip install --upgrade Distribute如果您已经安装了它,pip可能必须pip2做,并且在某些系统上(它是我的)可能需要使用Python2。

Bear in mind you may have to do pip install --upgrade Distribute if you have it installed already and your pip may be called pip2 for Python2 on some systems (it is on mine).


回答 3

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

sudo pip install --upgrade setuptools

不适用于我,我认为我的setuptools / distribute安装程序很烂。

我终于通过运行使它起作用

sudo easy_install -U setuptools

I had this issue, as well as some other issues with Brewed Python on OS X v10.9 (Mavericks).

sudo pip install --upgrade setuptools

didn’t work for me, and I think my setuptools/distribute setup was botched.

I finally got it to work by running

sudo easy_install -U setuptools

回答 4

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

下载ez_setup.py下载setuptools的(请参阅“安装说明”部分),则:

$ sudo python ez_setup.py

我希望它可以节省一些时间。

None of the above worked for me on Ubuntu 12.04 LTS (Precise Pangolin), and here’s how I fixed it in the end:

Download ez_setup.py from download setuptools (see “Installation Instructions” section) then:

$ sudo python ez_setup.py

I hope it saves someone some time.


回答 5

当您尝试安装时,可能会发生此错误pycurl

在这种情况下,您应该

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

(在这里找到:https : //gist.github.com/lxneng/1031014

This error can occur when you trying to install pycurl.

In this case you should do

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

(founded here: https://gist.github.com/lxneng/1031014 )


回答 6

在CentOS 6.5上,全新安装的简短回答是:

yum -y install python-pip pip install -U pip pip install -U setuptools pip install -U setuptools

您不会看到两倍,必须运行两次setuptools升级。长答案如下:

python-pip使用yum 安装软件包会带来python-setuptools依赖性。这是一个很旧的版本,因此实际上是在安装distribute (0.6.10)。安装软件包管理器后,我们通常要对其进行更新,因此我们pip install -U pip。对我来说,当前的pip版本是1.5.6。

现在我们去更新setuptools,这个pip版本很聪明,知道它应该先删除旧版本的distribution。它会执行此操作,但是会安装而不是安装最新版本的setuptools setuptools (0.6c11)

此时,由于setuptools的版本太旧,各种情况都被破坏了,但实际上我们已经到了一半。如果现在第二次运行完全相同的命令pip install -U setuptools,则将删除旧版本的setuptools,并安装5.5.1版。我不知道为什么pip不能一口气将我们带到新版本,但这是正在发生的事情,希望它将帮助其他人看到这一点并知道您不会发疯。

On CentOS 6.5, the short answer from a clean install is:

yum -y install python-pip pip install -U pip pip install -U setuptools pip install -U setuptools

You are not seeing double, you must run the setuptools upgrade twice. The long answer is below:

Installing the python-pip package using yum brings python-setuptools along as a dependency. It’s a pretty old version and hence it’s actually installing distribute (0.6.10). After installing a package manager we generally want to update it, so we do pip install -U pip. Current version of pip for me is 1.5.6.

Now we go to update setuptools and this version of pip is smart enough to know it should remove the old version of distribute first. It does this, but then instead of installing the latest version of setuptools it installs setuptools (0.6c11).

At this point all kinds of things are broken due to this extremely old version of setuptools, but we’re actually halfway there. If we now run the exact same command a second time, pip install -U setuptools, the old version of setuptools is removed, and version 5.5.1 is installed. I don’t know why pip doesn’t take us straight to the new version in one shot, but this is what’s happening and hopefully it will help others to see this and know you’re not going crazy.


回答 7

看起来默认的easy_install在其当前位置已损坏:

$ which easy_install /usr/bin/easy_install

解决此问题的一种方法是在站点包中使用easy_install。例如:

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

Looks like the default easy_install is broken in its current location:

$ which easy_install /usr/bin/easy_install

A way to overcome this is to use the easy_install in site packages. For example:

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


回答 8

我遇到了同样的问题,并且尝试了以上所有答案。但不幸的是,以上方法均无效。

作为说明,我终于通过解决了这个问题pip uninstall distribute

I was facing the same issue and I tried all the above answers. But unfortunately, none of the above worked.

As a note, I finally solve this by pip uninstall distribute.


回答 9

我知道这是一个较旧的问题,但这是我用来cassandra-driver实际安装在Windows 7 / Python2上的步骤。我家里有Windows 10 / 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; DR解决方案

(我希望有人解释为什么这样做)

  • 尝试pip install 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++ Compiler for Python 2.7
  • 成功执行 pip install --pre cassandra-driver
  • 成功执行 pip uninstall cassandra-driver
  • 成功执行 pip install cassandra-driver

重申一下,我不太确定为什么这样做。现在我的两个主要结论是,不管是C ++编译器是必需的或者是运行--pre在第一时间安装一些依赖人失踪,从选项“正规军”安装。当我有更多详细信息时,我将在今晚下班后更新。

I know this is an older question but here are the steps I used to get cassandra-driver to actually install on Windows 7 / Python2. I have windows 10 / Python3 at home where I will test this tonight. I have confirmed this also works on Windows 10 with both Python 2 and 3.

Problem

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

TL;DR Solution

Solution (I’d love for someone to explain why this worked)

  • Attempted pip install cassandra-driver and got the above error message
  • Attempted pip install --pre cassandra-driver and got the following error
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
  • Installed Microsoft Visual C++ Compiler for Python 2.7
  • Successfully executed pip install --pre cassandra-driver
  • Successfully executed pip uninstall cassandra-driver
  • Successfully executed pip install cassandra-driver

To reiterate, I’m not really sure why this worked. Right now my two leading conclusions are that either the C++ compiler is required or that running the --pre option the first time installed some dependencies that were missing from the ‘regular’ install. I’ll update tonight after work when I have more details.


回答 10

pip install -U setuptools并且easy_install将egg-info放在错误的目录中。

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

pip install -U setuptools and easy_install was putting egg-info in the wrong directory.

Then I just reinstalled apt-get install python-dev. Let me install the drivers I want after that


回答 11

尝试以下命令:

pip install setuptools==28.8.0

try the following command:

pip install setuptools==28.8.0

回答 12

我只是将liquidki的答案转换为Ubuntu命令。在基于Ubuntu的系统上,它可以工作!:

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

I just convert liquidki’s answer into Ubuntu commands. On an Ubuntu based system it works!:

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

回答 13

对我来说,将点数从8.1.1升级到9.0.1解决了此问题。

您可以运行类似sudo -H pip2 install --upgrade pip升级pip版本的操作。

For me upgrading pip from 8.1.1 to 9.0.1 solved this problem.

You can run something like sudo -H pip2 install --upgrade pip to upgrade your pip version.


回答 14

当我想在虚拟环境中使用命令安装cairosvg时,我也遇到类似的错误消息“命令’python setup.py egg_info’失败,错误代码为1” pip install cairosvg

然后,我曾经尝试都pip install --upgrade pippip install --upgrade setuptools运行前pip3 install cairosvg,但我仍然得到这个错误。

我可以摆脱这个错误与须藤在安装命令前:sudo pip install cairosvg。但请注意,带有sudo的命令将为系统python而非虚拟环境安装软件包。

因此,我进一步检查了错误消息,并发现在安装cairocffi时收到错误消息。然后安装特定版本的cairocffi(请参阅此答案在安装cairosvg之前,先安装)。这就是我解决问题的方式。

I also meet a similar error message “Command ‘python setup.py egg_info’ failed with error code 1” when I want to install cairosvg with command pip install cairosvg in a virtual environment.

Then I have tried both pip install --upgrade pip and pip install --upgrade setuptools before running pip3 install cairosvg, but I still get this error.

I can get rid of this error with sudo in front of the installation command : sudo pip install cairosvg. But note that the command with sudo will install the package for the system python rather than the virtual environment.

So, I further check the error message and find that I get the error while installing the cairocffi. Then I install a certain version of cairocffi (refer to this answer) before install cairosvg. That is how I solve my problem.


声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。