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

前端 未结 10 641
灰色年华
灰色年华 2020-12-22 19:03

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 f

相关标签:
10条回答
  • 2020-12-22 19:55

    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)

    0 讨论(0)
  • 2020-12-22 19:55

    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

    0 讨论(0)
  • 2020-12-22 19:59
    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.

    0 讨论(0)
  • 2020-12-22 20:00

    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

    0 讨论(0)
提交回复
热议问题