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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17498256/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 08:20:33  来源:igfitidea点击:

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

pythonvirtualenv

提问by

I was trying to work on Pyladies website on my local folder. I cloned the repo, (https://github.com/pyladies/pyladies) ! and created the virtual environment. However when I do the pip install -r requirements, I am getting this error

我试图在我的本地文件夹上的 Pyladies 网站上工作。我克隆了 repo,(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.

I tried doing this, sudo port install libevent CFLAGS="-I /opt/local/include -L /opt/local/lib" pip install gevent

我尝试这样做, sudo port install libevent CFLAGS="-I /opt/local/include -L /opt/local/lib" pip install gevent

It says port command not found.

它说找不到端口命令。

I am not sure how to proceed with this. Thanks!

我不知道如何继续。谢谢!

采纳答案by KhalilRavanna

I had the same problem and just as the other answer suggested I had to install "libevent". It's apparently not called "libevent-devel" anymore (apt-get couldn't find it) but doing:

我遇到了同样的问题,正如其他答案所建议的那样,我必须安装“libevent”。它显然不再被称为“libevent-devel”(apt-get 找不到),而是执行以下操作:

    $ apt-cache search libevent

listed a bunch of available packages.

列出了一堆可用的包。

    $ apt-get install libevent-dev 

worked for me.

为我工作。

回答by seanxiaoxiao

I think you just forget to install the "libevent" in the environment. If you are on a OSX machine, please try to install brew here http://mxcl.github.io/homebrew/and use brew install libevent to install the dependency. If you are on an ubuntu machine, you can try apt-get to install the corresponding library.

我认为您只是忘记在环境中安装“libevent”。如果您使用的是 OSX 机器,请尝试在http://mxcl.github.io/homebrew/上安装 brew,并使用 brew install libevent 安装依赖项。如果你在ubuntu机器上,可以试试apt-get安装对应的库。

回答by rosterloh

I had this issue while trying to

我在尝试时遇到了这个问题

pip install Flask-Sockets

and

sudo apt-get install libevent-dev

worked for me

为我工作

回答by Jason Zou

yum install libevent-* 

This command works for me because I am on centos.

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

回答by Rich Vogt

I ran into this error on MacOS 10.10.1 (Yosemite) running pip install. The solution for me was to add the path to libevent which pip was missing. These are C files, and CFLAGS and DFLAGS are bash environment variables that let pip know where to find these files. On my system, libevent is found at /usr/local/include/event2.

我在运行 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