How can I install the Python library 'gevent' on Mac OS X Lion

不羁的心 提交于 2019-11-29 19:04:48
Dietrich Epp

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)

Legolas Bloom
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.

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
sandman

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.

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

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

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

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.

user200778
sudo pip install cython git+git://github.com/gevent/gevent.git#egg=gevent
sandip

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!