在通过python setup.py install 安装gevent后,使用gevent时提示如下错误:
# python2.6
Python 2.6.7 (r267:88850, Sep 6 2011, 08:13:16)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gevent
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/gevent/__init__.py", line 41, in <module>
File "build/bdist.linux-x86_64/egg/gevent/core.py", line 7, in <module>
File "build/bdist.linux-x86_64/egg/gevent/core.py", line 6, in __bootstrap__
ImportError: /root/.python-eggs/gevent-0.13.6-py2.6-linux-x86_64.egg-tmp/gevent/core.so: undefined symbol: event_global_current_base_
>>>
undefined symbol: event_global_current_base_ 究竟是怎么回事?
gevent依赖于libevent,而且gevent对libevent1.4支持不怎么地,怀疑是编译安装gevent时使用的是libevent1.X
通过 ldd 查看究竟使用的是哪个libevent
ldd /gevent-0.13.6/gevent/core.so
如果机器上安装有多个libevent版本,则最好在编译安装gevent时指定libevent路径,
例如:
python2.6 setup.py build --libevent /opt/uploadavml/libevent-2.0.17-stable
python2.6 setup.py install
强烈建议将gevent搭配libevent2.0.17及其以上版本使用,测试时发现gevent搭配libevent2.0.10是出问题的!!