如何安装 Python 库“gevent”?在 Mac OS X Lion 上

发布于 2024-12-07 13:42:07 字数 3020 浏览 1 评论 0原文

Python 库 gevent,版本 0.13.6(PyPI 上的当前版本)不会在 OS X Lion、Python 2.7(可能还有其他版本)上 pip install。它可以正常工作雪豹。

我怎样才能安装这个库?

如果可以使用 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

Python library gevent, version 0.13.6 (the current version on PyPI) will not pip install on OS X Lion, Python 2.7 (and probably others.) It works fine on Snow Leopard.

How can I get this library installed?

Bonus points if it can be done using pip install, rather than a manual or custom process, because then it will play nicely with automated builds.

Here is my pip install output:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

忘羡 2024-12-14 13:42:07

不要发布整个内容!这太过分了! 90% 的情况下,第一个错误就足够了...

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

这意味着未安装提供 event.h 标头的库。该库称为 libevent(网站)。

一般来说,像这样的编译错误是构建脚本中的缺陷。构建脚本应该给出一条错误消息,指出 libevent 未安装,而它没有这样做是一个错误。

从 MacPorts 获取 libevent,然后在运行 pip 时使用 CFLAGS 环境变量手动告诉编译器在哪里可以找到 event.hlibevent

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

您还可以使用 homebrew 安装 libevent : brew install libevent
(来自大卫·沃尔弗的评论)

Don't post the entire thing! That's too much! 90% of the time, the first error is enough...

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

This means that the library which provides the event.h header is not installed. The library is called libevent (website).

In general, compilation errors like these are a flaw in the build scripts. The build script should give an error message that libevent is not installed, and it is a bug that it did not do so.

To get libevent from MacPorts and then manually tell compiler with CFLAGS environment variable where to find event.h and libevent while running pip.

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

You can also use homebrew for installing libevent : brew install libevent
(from David Wolever's comment)

就是爱搞怪 2024-12-14 13:42:07
CFLAGS='-std=c99' pip install gevent

请参阅:无法

在 OS X 10.11 上安装 gevent OSX 10.11,clang默认使用 c11,因此只需将其转回 c99 即可。

CFLAGS='-std=c99' pip install gevent

See in: Can't install gevent OSX 10.11

on OS X 10.11, clang uses c11 as the default, so just turn it back to c99.

幻梦 2024-12-14 13:42:07

一段时间后,我意识到上面提到的 CFLAGS 变量的路径在从 port 安装 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

After a while, I realized that the paths for the CFLAGS variable mentioned above works when installing libevent from port, but not from brew. The following worked for me (on 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
春花秋月 2024-12-14 13:42:07

这是我发现最简单的方法:

安装 libevent

$ brew install libevent

使用 homebrew install gevent

$ pip install gevent

这是我可以让它工作的唯一方法。

This is the way I found the easiest:

install libevent using homebrew

$ brew install libevent

install gevent

$ pip install gevent

This was the only way I could get it to work.

z祗昰~ 2024-12-14 13:42:07

在寻求在 Snow Leopard 上安装的帮助时找到了这个答案,发布此答案以防其他人遇到同样的问题。

我通过 macports 安装了 libevent。

导出 CFLAGS=-I/opt/local/include
导出 LDFLAGS=-L/opt/local/lib
sudo pip 安装 gevent

Found this answer when looking for help installing on Snow Leopard, posting this in case someone else comes this way with the same problem.

I had libevent installed via macports.

export CFLAGS=-I/opt/local/include
export LDFLAGS=-L/opt/local/lib
sudo pip install gevent

掐死时间 2024-12-14 13:42:07

我通过brew安装了libevent,它也失败了,工作原理与Stephen所做的类似,但指向brew默认安装:

CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib pip install gevent

I had libevent installed via brew and it failed too, what worked was similar to what Stephen done, but pointing to brew default install:

CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib pip install gevent

骄兵必败 2024-12-14 13:42:07

如果您从源安装所有内容并使用 csh,则以下内容适用于 mac os 10.9

  1. 下载最新的稳定版 http://libevent.org / libevent-2.0.21-stable

    • ./配置
    • 制作
    • sudo make install
  2. virtualenv env

  3. source env/bin/activate.csh

  4. setenv CFLAGS "-I /usr/local/include -L /usr/local/lib"

  5. pip install gevent

In case you install all from sources and use csh the following works on mac os 10.9

  1. download latest stable http://libevent.org/ libevent-2.0.21-stable

    • ./configure
    • make
    • sudo make install
  2. virtualenv env

  3. source env/bin/activate.csh

  4. setenv CFLAGS "-I /usr/local/include -L /usr/local/lib"

  5. pip install gevent

流心雨 2024-12-14 13:42:07

我使用 virtualenv 和 virtualenv 包装器,所以我希望它是独立的。我让 gevent 像这样工作:

假设您有虚拟环境设置,然后:

workon {my_virtual_env}

然后下载 libevent 并将其安装到虚拟环境中。

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)

希望这有帮助。

I use virtualenv and virtualenv wrapper, and so I wanted this to be self contained. I got gevent working like so:

Assuming you have virtual env setup, then:

workon {my_virtual_env}

Then download libevent and install it against the 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

I'm assuming you've got gcc 5+ installed (I use brew)

Hope this helps.

七月上 2024-12-14 13:42:07
sudo pip install cython git+git://github.com/gevent/gevent.git#egg=gevent
sudo pip install cython git+git://github.com/gevent/gevent.git#egg=gevent
冷了相思 2024-12-14 13:42:07

我正在使用 MacOs High Sierra (10.13.3)
首先我做了:
brew install libevent

我将 pip 版本升级到 pip-18.0。
然后尝试再次安装以下内容:-

pip install gevent

它有效。

I am using MacOs High Sierra (10.13.3)
First I did :
brew install libevent

I upgraded my pip version to pip-18.0.
then tried installing again with following :-

pip install gevent

it worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文