当前位置: 首页>>技术教程>>正文


python – 错误:安装eventlet时,命令’gcc’失败,退出状态为1

, ,

问题描述

我想在我的系统上安装eventlet,以便使用”Herd”进行软件部署。.但是终端显示了gcc错误:

  root@agrover-OptiPlex-780:~# easy_install -U eventlet
  Searching for eventlet
  Reading http://pypi.python.org/simple/eventlet/
  Reading http://wiki.secondlife.com/wiki/Eventlet
  Reading http://eventlet.net
   Best match: eventlet 0.9.16
    Processing eventlet-0.9.16-py2.7.egg
    eventlet 0.9.16 is already the active version in easy-install.pth

   Using /usr/local/lib/python2.7/dist-packages/eventlet-0.9.16-py2.7.egg
 Processing dependencies for eventlet
 Searching for greenlet>=0.3
Reading http://pypi.python.org/simple/greenlet/
Reading https://github.com/python-greenlet/greenlet
Reading http://bitbucket.org/ambroff/greenlet
Best match: greenlet 0.3.4
Downloading http://pypi.python.org/packages/source/g/greenlet/greenlet-   0.3.4.zip#md5=530a69acebbb0d66eb5abd83523d8272
Processing greenlet-0.3.4.zip
Writing /tmp/easy_install-_aeHYm/greenlet-0.3.4/setup.cfg
Running greenlet-0.3.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-_aeHYm/greenlet-0.3.4/egg-dist-tmp-t9_gbW
In file included from greenlet.c:5:0:
greenlet.h:8:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1`

为什么找不到Python.h

最佳思路

您的安装失败,因为您没有安装python开发标头。您可以通过在ubuntu /debian上通过apt来执行以下操作:

sudo apt-get install python-dev 

对于python3使用:

sudo apt-get install python3-dev

对于eventlet,您可能还需要安装libevent库,因此,如果在谈论该错误时可以使用以下命令安装libevent:

sudo apt-get install libevent-dev

次佳思路

对于Fedora:

sudo yum install python-devel

sudo yum install libevent-devel

最后:

sudo easy_install gevent

第三种思路

我尝试了以上所有答案。但是对我有用的是CentOS:

sudo yum -y install gcc
sudo yum install python-devel

第四种思路

对于Redhat版本(Centos 7),使用以下命令安装Python开发包

Python 2.7

sudo yum install python-dev

Python 3.4

sudo yum install python34-devel

如果您的问题仍未解决,请尝试安装以下软件包-

sudo yum install python-devel

sudo yum install openssl-devel

sudo yum install libffi-devel

第五种思路

在MacOS上,我无法安装需要pystanfbprophet,而需要gcc进行编译。我将始终遇到相同的错误:命令’gcc’失败,退出状态为1

我想我自己解决了这个问题:

我使用brew install gcc安装了最新版本,最终成为gcc-8

然后,我确保当gcc运行时,它将改为使用gcc-8

之所以起作用,是因为我在我的.zshrc中添加了alias gcc='gcc-8(与zzsh的.bashrc相同),或者因为我运行了export PATH=/usr/local/bin:$PATH(请参阅comment)

另外:我所有的尝试都在虚拟环境中进行,并且仅通过在全球范围内安装fbprophet(通过pip)获得了成功,但在venv中仍然没有成功

第六种思路

对于CentOS 7.2:

LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.2.1511 (Core) 
Release:    7.2.1511
Codename:   Core

安装事件:

sudo yum install python-devel
sudo easy_install -ZU eventlet

码头信息:

[root@localhost ~]# easy_install -ZU eventlet
Searching for eventlet
Reading http://pypi.python.org/simple/eventlet/
Best match: eventlet 0.19.0
Downloading https://pypi.python.org/packages/5a/e8/ac80f330a80c18113df0f4f872fb741974ad2179f8c2a5e3e45f40214cef/eventlet-0.19.0.tar.gz#md5=fde857181347d5b7b921541367a99204
Processing eventlet-0.19.0.tar.gz
Running eventlet-0.19.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-Hh9GQY/eventlet-0.19.0/egg-dist-tmp-rBFoAx
Adding eventlet 0.19.0 to easy-install.pth file

Installed /usr/lib/python2.6/site-packages/eventlet-0.19.0-py2.6.egg
Processing dependencies for eventlet
Finished processing dependencies for eventlet

第七种思路

尝试这个 :

sudo apt-get install libblas-dev libatlas-base-dev

我在Ubuntu 14.04上遇到了类似的问题。对我来说以下Ubuntu软件包

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/9107.html,未经允许,请勿转载。