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


当前回答

如果你和我一样用Mac,在你的终端试试:xcode-select——install

然后接受安装请求,然后按照本问题中的描述工作

其他回答

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时遇到了麻烦,它需要pystan,需要gcc来编译。我会始终得到相同的错误:命令'gcc'失败退出状态1

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

我使用brew install gcc来安装最新的版本,最终是gcc-8

然后我确保gcc运行时使用gcc-8。

它可以工作,因为我在我的.zshrc中添加了别名gcc='gcc-8(与.bashrc相同,但用于zsh),或者因为我运行export PATH=/usr/local/bin:$PATH(见评论)

另外:我所有的尝试都是在虚拟环境中,我只成功地在全局安装了fbprophet(用pip),但在venv中仍然没有成功

Sudo apt安装GCC

它适用于Ubuntu 20.10上的PyCharm。

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

对于Alpine(>=3.6),使用

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

安装失败是因为没有安装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