web-dev-qa-db-ja.com

Mac OS X LionにPythonライブラリ 'gevent'をインストールする方法

Pythonライブラリgevent、バージョン0.13.6(PyPIの現在のバージョン)は、OS X Lionではpip installではありません、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
63
Jacob Lyles

全部を投稿しないでください!それは多すぎる! 90%の時間、最初のエラーで十分です...

 gevent/libevent.h:9:19:エラー:event.h:そのようなファイルまたはディレクトリはありません

これは、event.hヘッダーがインストールされていません。ライブラリはlibeventと呼ばれます( website )。

一般に、これらのようなコンパイルエラーはビルドスクリプトの欠陥です。ビルドスクリプトは、libeventがインストールされていないというエラーメッセージを表示する必要がありますが、インストールしなかったのはバグです。

MacPortsからlibeventを取得し、CFLAGS環境変数を使用してコンパイラに手動でevent.hおよびlibeventは、pipの実行中に。

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

Libbrewのインストールにhomebrewを使用することもできます:brew install libevent
(David Woleverのコメントより)

114
Dietrich Epp
CFLAGS='-std=c99' pip install gevent

参照: gevent OSX 10.11をインストールできません

oS X 10.11では、clangはc11をデフォルトとして使用するため、c99に戻します。

24
Legolas Bloom

しばらくして、ポートからlibeventをインストールするときに上記のCFLAGS変数のパスが機能するが、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
16

これは私が最も簡単に見つけた方法です:

homebrewを使用してlibeventをインストールする

$ brew install libevent

geventをインストールする

$ pip install gevent

これが私がそれを機能させることができる唯一の方法でした。

6
sandman

Snow Leopardへのインストールに関するヘルプを探しているときにこの回答を見つけました。他の誰かが同じ問題でこの方法でやってきた場合に備えて、これを投稿してください。

Libportをmacports経由でインストールしました。

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

4
Stephen

私はbrew経由でlibeventをインストールしましたが、それも失敗しました。動作はStephenが行ったものと似ていましたが、brewのデフォルトインストールを指しています。

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

2
Sudo pip install cython git+git://github.com/gevent/gevent.git#Egg=gevent
0
user200778

MacOs High Sierra(10.13.3)を最初に使用しました:libeventをインストールします

Pipバージョンをpip-18.0にアップグレードしました。その後、次のように再度インストールしてみました:-

pip install gevent

出来た。

0
sandip

ソースからすべてをインストールし、cshを使用する場合、次のMac OS 10.9で動作します

  1. 最新の安定版をダウンロード http://libevent.org/ libevent-2.0.21-stable

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

  3. ソースenv/bin/activate.csh

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

  5. pip install gevent

0
nbari

私はvirtualenvとvirtualenvラッパーを使用しているので、これが自己完結型であることを望みました。私はgeventを次のように動作させました:

仮想env設定があると仮定すると、次のようになります。

workon {my_virtual_env}

次に、libeventをダウンロードし、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

私はあなたがgcc 5+をインストールしていると仮定しています(私はbrewを使用しています)

お役に立てれば。

0
silverdagger