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

时间:2013-07-05 23:54:53

标签: python virtualenv

我正在尝试在我的本地文件夹上的Pyladies网站上工作。我克隆了回购,(https://github.com/pyladies/pyladies)!并创建了虚拟环境。但是,当我执行pip install -r要求时,我收到此错误

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

它表示未找到端口命令。

我不知道如何处理这个问题。谢谢!

5 个答案:

答案 0 :(得分:51)

我遇到了同样的问题,正如另一个答案建议我必须安装“libevent”。它显然不再被称为“libevent-devel”(apt-get无法找到它),而是在做:

    $ apt-cache search libevent

列出了一堆可用的包。

    $ apt-get install libevent-dev 

为我工作。

答案 1 :(得分:11)

我想你只是忘了在环境中安装“libevent”。如果您使用的是OSX计算机,请尝试在此处安装brew http://mxcl.github.io/homebrew/并使用brew install libevent安装依赖项。如果您使用的是ubuntu计算机,可以尝试使用apt-get来安装相应的库。

答案 2 :(得分:2)

我在尝试

时遇到了这个问题
pip install Flask-Sockets

sudo apt-get install libevent-dev

为我工作

答案 3 :(得分:1)

yum install libevent-* 

这个命令对我有用,因为我在使用centos。

答案 4 :(得分:1)

我在运行pip install的MacOS 10.10.1(Yosemite)上遇到此错误。对我来说,解决方案是添加路径以解决丢失pip的问题。这些是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