我想在我的系统上安装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 ?


当前回答

如果它仍然不能工作,您可以试试这个

sudo apt-get install build-essential

对我来说,它解决了问题。

其他回答

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

Python 2.7

sudo yum install python-dev

Python 3.4

sudo yum install python34-devel

Python 3.6

sudo yum install python36-devel

如果问题仍然没有解决,然后尝试安装以下包-

sudo yum install python-devel

sudo yum install openssl-devel

sudo yum install libffi-devel

这一页将拯救你的生命,为所有即将到来的自由问题,

对于Alpine(>=3.6),使用

apk --update --upgrade add gcc musl-dev jpeg-dev zlib-dev libffi-dev cairo-dev pango-dev gdk-pixbuf-dev

如果您正在迁移到更现代的python3版本,例如python3.5到python3.8,如果您已经安装了推荐的库来处理gcc构建python3-dev +其他建议的库,则可能需要检查/升级正在失败的库版本。

这取决于包装。python3的后续版本可能不支持这些包的某些版本。

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

在MacOS上,我也有问题,试图安装fbprophet有gcc作为其依赖项之一。

在尝试了@Boris推荐的几个步骤后,下面来自Facebook先知项目页面的命令最终对我有用。

conda install -c conda-forge fbprophet

它安装了fbprophet所需的所有依赖项。确保你已经安装了anaconda。