Programing

Mac OS X Lion에 Python 라이브러리 'gevent'를 설치하려면 어떻게해야합니까?

lottogame 2020. 11. 23. 07:40
반응형

Mac OS X Lion에 Python 라이브러리 'gevent'를 설치하려면 어떻게해야합니까?


Python 라이브러리 gevent, 버전 0.13.6 (PyPI의 현재 버전)은 pip installOS X Lion, Python 2.7 (및 기타)에서는 작동 하지 않습니다 . Snow Leopard에서는 잘 작동합니다.

이 라이브러리를 설치하려면 어떻게해야합니까?

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

모든 것을 게시하지 마십시오! 너무 많습니다! 90 %의 경우 첫 번째 오류로 충분합니다 ...

gevent / libevent.h : 9 : 19 : 오류 : event.h : 해당 파일 또는 디렉토리가 없습니다.

이는 event.h헤더 를 제공하는 라이브러리 가 설치되지 않았 음 을 의미합니다 . 라이브러리는 libevent ( 웹 사이트 ) 라고 합니다.

일반적으로 이와 같은 컴파일 오류는 빌드 스크립트의 결함입니다. 빌드 스크립트는 libevent가 설치되지 않았다는 오류 메시지를 제공해야하며 설치하지 않은 버그입니다.

MacPorts의에서 libevent를 얻고 수동으로 컴파일러에게 CFLAGS어디에서 찾을 수있는 환경 변수 event.hlibevent핍을 실행하는 동안.

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

libevent 설치에 homebrew를 사용할 수도 있습니다. brew install libevent
(David Wolever의 의견에서)


CFLAGS='-std=c99' pip install gevent

참조 : gevent OSX 10.11을 설치할 수 없음

OS X 10.11에서 clang은 c11을 기본값으로 사용하므로 c99로 되 돌리십시오.


잠시 후 위에서 언급 한 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

이것이 내가 가장 쉬운 방법을 찾은 것입니다.

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.


sudo pip install cython git+git://github.com/gevent/gevent.git#egg=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.

참고URL : https://stackoverflow.com/questions/7630388/how-can-i-install-the-python-library-gevent-on-mac-os-x-lion

반응형