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


当前回答

这是一篇旧文章,但我只是在AWS EC2安装regex时遇到了同样的问题。这对我来说很有效

sudo yum -y install gcc

和明年

sudo yum -y install gcc-c++

其他回答

我使用的是MacOS catalina 10.15.4。上面的解决方案对我来说都没用。对我有用的是:

 >> xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

>> env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install psycopg2==2.8.4
Collecting psycopg2==2.8.4
  Using cached psycopg2-2.8.4.tar.gz (377 kB)
Installing collected packages: psycopg2
  Attempting uninstall: psycopg2
    Found existing installation: psycopg2 2.7.7
    Uninstalling psycopg2-2.7.7:
      Successfully uninstalled psycopg2-2.7.7
    Running setup.py install for psycopg2 ... done
Successfully installed psycopg2-2.8.4

对python3使用pip3

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

sudo apt-get install build-essential

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

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

这是一篇旧文章,但我只是在AWS EC2安装regex时遇到了同样的问题。这对我来说很有效

sudo yum -y install gcc

和明年

sudo yum -y install gcc-c++

试试这个:

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

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