How to install Python 'gevent' library on Mac OS X Lion

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

How can I install this library?

Bonus points, if this can be done using pip install , rather than a manual or custom process, because then it will play well with automatic 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 
+63
python osx-lion gevent macos
Oct 03 2018-11-11T00:
source share
9 answers

Do not publish everything! 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 that provides the event.h header is not installed. The library is called libevent ( site ).

In general, compilation errors like these are a flaw in build scripts. An error message should appear in the assembly of the script that libevent is not installed, and this is an error due to which it did not do this.

To get libevent from MacPorts, then manually tell the compiler with the CFLAGS environment variable where you can find event.h and libevent when pip starts.

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

You can also use the hometown to install libevent: brew install libevent
(from a comment by David Wolever)

+114
03 Oct 2018-11-11T00:
source share
 CFLAGS='-std=c99' pip install gevent 

See: Unable to install gevent OSX 10.11

on OS X 10.11, clang uses the default value of c11, so just push it back to c99.

+22
Oct 30 '15 at 6:38
source share

After some time, I realized that the paths for the CFLAGS variable mentioned above work when installing libevent from the 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 
+14
Oct 24 '13 at 19:02
source share

So I found the easiest one:

install libevent using homebrew

 $ brew install libevent 

install gevent

 $ pip install gevent 

That was the only way to make it work.

+6
Aug 09 '13 at 0:34
source share

I found this answer when looking for help on Snow Leopard, posting it in case someone else comes up 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

+4
Feb 23 '13 at 18:45
source share

I had a libevent installed via brew, and it also failed, which worked, it was similar to what Stephen did, but pointing to brew default install:

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

+2
Aug 27 '13 at 20:43
source share

If you install everything from sources and use csh, the following works on Mac OS 10.9

  • download the latest version http://libevent.org/ libevent-2.0.21-stable

    • ./Configure
    • to do
    • sudo make install
  • virtualenv env

  • source env / bin / activate.csh

  • setenv CFLAGS "-I / usr / local / include -L / usr / local / lib"

  • pip install gevent

0
Oct 26 '13 at 22:25
source share

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

Assuming you have a virtual installation of env, then:

 workon {my_virtual_env} 

Then download libevent and install it against 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 assume you have gcc 5+ installed (I use brew)

Hope this helps.

0
Sep 06 '15 at 1:58
source share
 sudo pip install cython git+git://github.com/gevent/gevent.git#egg=gevent 
0
Sep 20 '15 at 8:02
source share



All Articles