gevent/libevent.h:9:19: 致命错误:event.h:没有那个文件或目录

21

我想在本地文件夹上处理Pyladies网站。我克隆了存储库 (https://github.com/pyladies/pyladies) 并创建了虚拟环境。然而,当我运行pip install -r requirements时,出现了以下错误

Installing collected packages: gevent, greenlet
Running setup.py install for gevent
building 'gevent.core' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -I/opt/local/include -fPIC -I/usr/include/python2.7 -c gevent/core.c -o build/temp.linux-i686-2.7/gevent/core.o
In file included from gevent/core.c:253:0:
gevent/libevent.h:9:19: fatal error: event.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
Complete output from command /home/akoppad/virt/pyladies/bin/python -c "import setuptools;__file__='/home/akoppad/virt/pyladies/build/gevent/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-4MSIGy-record/install-record.txt --install-headers /home/akoppad/virt/pyladies/include/site/python2.7:
running install

running build

running build_py

running build_ext

building 'gevent.core' extension

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -I/opt/local/include -fPIC -I/usr/include/python2.7 -c gevent/core.c -o build/temp.linux-i686-2.7/gevent/core.o

In file included from gevent/core.c:253:0:

gevent/libevent.h:9:19: fatal error: event.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1

----------------------------------------
Command /home/akoppad/virt/pyladies/bin/python -c "import setuptools;__file__='/home/akoppad/virt/pyladies/build/gevent/setup.py';   exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-4MSIGy-record/install-record.txt --install-headers /home/akoppad/virt/pyladies/include/site/python2.7 failed with error code 1 in /home/akoppad/virt/pyladies/build/gevent
Storing complete log in /home/akoppad/.pip/pip.log.

我尝试执行以下命令: sudo port install libevent CFLAGS="-I /opt/local/include -L /opt/local/lib" pip install gevent

但它显示“port命令找不到”。

我不确定该怎么继续操作。谢谢!

5个回答

52
我遇到了同样的问题,正如其他答案所建议的一样,我需要安装“libevent”。显然它现在不再称为“libevent-devel”(apt-get找不到它),但操作以下命令即可:
    $ apt-cache search libevent

列出了许多可用的软件包。

    $ apt-get install libevent-dev 

对我有用。


太完美了!简直棒极了 :) - softvar
这个解决方案应该标记为正确的,而不是另一个。 - Dan Ciborowski - MSFT

11

我认为您只是忘记在环境中安装“libevent”了。如果您正在使用OSX机器,请尝试在这里安装brew http://mxcl.github.io/homebrew/ 并使用 brew install libevent 命令安装该库。如果您正在使用ubuntu机器,可以尝试使用 apt-get 命令安装相应的库。


非常感谢。我试图在虚拟环境中执行sudo apt-get install libevent-devel。因此出现错误。我在虚拟环境外正常安装它,然后它以正常方式安装。再次感谢! - user2459905

2
我在尝试时遇到了这个问题:
pip install Flask-Sockets

并且

sudo apt-get install libevent-dev

对我有用。

1
我在运行pip install时遇到了这个错误,我的操作系统是MacOS 10.10.1 (Yosemite)。对我来说解决方案是添加pip缺失的libevent路径。这些是C文件,CFLAGS和DFLAGS是bash环境变量,让pip知道在哪里找到这些文件。在我的系统上,libevent位于/usr/local/include/event2。
$ CFLAGS=-I/usr/local/include/event2 DFLAGS=-L/usr/local/lib pip install -r requires.txt

1
yum install libevent-* 

这个命令对我有效,因为我在CentOS上。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接