Python库gevent
,版本0.13.6(PyPI上的当前版本)在OS X Lion,Python 2.7(以及可能还有其他版本)上不会pip install
。它在Snow Leopard上运行正常。< / p>
如何安装此库?
如果可以使用pip install
而不是手动或自定义流程完成奖励积分,因为它可以很好地与自动构建一起使用。
这是我的pip install
输出:
pip install gevent
Downloading/unpacking gevent
Running setup.py egg_info for package gevent
Requirement already satisfied (use --upgrade to upgrade): greenlet in ./tl_env/lib/python2.7/site-packages (from gevent)
Installing collected packages: gevent
Running setup.py install for gevent
building 'gevent.core' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c gevent/core.c -o build/temp.macosx-10.6-intel-2.7/gevent/core.o
In file included from gevent/core.c:225:
gevent/libevent.h:9:19: error: event.h: No such file or directory
gevent/libevent.h:38:20: error: evhttp.h: No such file or directory
gevent/libevent.h:39:19: error: evdns.h: No such file or directory
gevent/core.c:361: error: field ‘ev’ has incomplete type
gevent/core.c:741: warning: parameter names (without types) in function declaration
gevent/core.c: In function ‘__pyx_f_6gevent_4core___event_handler’:
gevent/core.c:1619: error: ‘EV_READ’ undeclared (first use in this function)
gevent/core.c:1619: error: (Each undeclared identifier is reported only once
gevent/core.c:15376: warning: assignment makes pointer from integer without a cast
[... about 1000 more lines of compiler errors...]
gevent/core.c:15385: error: dereferencing pointer to incomplete type
gevent/core.c: In function ‘__pyx_pf_6gevent_4core_4http___init__’:
gevent/core.c:15559: warning: assignment makes pointer from integer without a cast
gevent/core.c: At top level:
gevent/core.c:21272: error: expected ‘)’ before ‘val’
lipo: can't figure out the architecture type of: /var/folders/s5/t94kn0p10hdgxzx9_9sprpg40000gq/T//cczk54q7.out
error: command 'gcc-4.2' failed with exit status 1
Complete output from command /Users/jacob/code/toplevel/tl_env/bin/python -c "import setuptools;__file__='/Users/jacob/code/toplevel/tl_env/build/gevent/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /var/folders/s5/t94kn0p10hdgxzx9_9sprpg40000gq/T/pip-s2hPd3-record/install-record.txt --install-headers /Users/jacob/code/toplevel/tl_env/bin/../include/site/python2.7:
running install
running build
running build_py
running build_ext
building 'gevent.core' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c gevent/core.c -o build/temp.macosx-10.6-intel-2.7/gevent/core.o
答案 0 :(得分:114)
不发布整件事!这太多了! 90%的时间,第一个错误就足够了......
gevent/libevent.h:9:19: error: event.h: No such file or directory
这意味着未安装提供event.h
标头的库。该库名为libevent(website)。
通常,像这样的编译错误是构建脚本中的一个缺陷。构建脚本应该给出一个错误消息,表明没有安装libevent,这是一个它没有这样做的错误。
从MacPorts获取libevent,然后手动告诉编译器CFLAGS
环境变量在运行pip时查找event.h
和libevent
的位置。
sudo port install libevent
CFLAGS="-I /opt/local/include -L /opt/local/lib" pip install gevent
您也可以使用自制软件来安装libevent:brew install libevent
(来自David Wolever的评论)
答案 1 :(得分:24)
CFLAGS='-std=c99' pip install gevent
见:Can't install gevent OSX 10.11
在OS X 10.11上,clang使用c11作为默认值,所以只需将其转回c99。
答案 2 :(得分:16)
过了一会儿,我意识到上面提到的CFLAGS变量的路径在从端口安装libevent时起作用,但不是从brew中安装。以下对我有用(在OSX Mavericks上):
$ brew install libevent
$ export CFLAGS="-I /usr/local/Cellar/libevent/2.0.21/include -L /usr/local/Cellar/libevent/2.0.21/lib"
$ pip install gevent
答案 3 :(得分:6)
这是我发现最简单的方式:
使用自制软件安装libevent
$ brew install libevent
安装gevent
$ pip install gevent
这是我能让它发挥作用的唯一方法。
答案 4 :(得分:4)
在寻找Snow Leopard安装帮助时找到了这个答案,发布此问题以防其他人以同样的方式解决这个问题。
我通过macports安装了libevent。
导出CFLAGS = -I / opt / local / include export LDFLAGS = -L / opt / local / lib sudo pip install gevent
答案 5 :(得分:2)
我通过brew安装了libevent,它也失败了,有什么效果与Stephen做的相似,但指向brew默认安装:
CFLAGS = -I / usr / local / include LDFLAGS = -L / usr / local / lib pip install gevent
答案 6 :(得分:0)
如果您从源安装所有内容并使用csh,则以下内容适用于mac os 10.9
下载最新的稳定http://libevent.org/ libevent-2.0.21-stable
virtualenv env
source env / bin / activate.csh
setenv CFLAGS“-I / usr / local / include -L / usr / local / lib”
pip install gevent
答案 7 :(得分:0)
我使用virtualenv和virtualenv包装器,所以我希望这是自包含的。我让gevent像这样工作:
假设你有虚拟环境设置,那么:
workon {my_virtual_env}
然后下载libevent并针对virtualenv进行安装。
curl -L -O https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar -xzf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix="$VIRTUAL_ENV"
make && make install
我假设你已经安装了gcc 5+(我使用brew)
希望这有帮助。
答案 8 :(得分:0)
我正在使用MacOs High Sierra(10.13.3) 首先,我做了: brew安装libevent
我将我的pip版本升级到pip-18.0。 然后尝试重新安装以下内容:-
pip install gevent
有效。