尝试在Python中使用gevent库:“ImportError:无法导入名称核心”
我正在尝试在我正在编写的 Python 应用程序中使用 gevent 库。但是,easy_install 和手动安装似乎都失败了。有什么建议吗?
Python 2.6.2 (r262:71600, Aug 5 2009, 10:31:21)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] 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 "gevent/__init__.py", line 28, in <module>
from gevent.greenlet import Greenlet, joinall, killall
File "gevent/greenlet.py", line 5, in <module>
from gevent import core
ImportError: cannot import name core
>>>
我的“构建”和“安装”命令的完整转储是:
(env)[root@test1:downloads/gevent-0.10.0]# python setup.py build (02-20 16:00)
found system libevent for linux2
running build
running build_py
creating build/lib.linux-i686-2.6
creating build/lib.linux-i686-2.6/gevent
copying gevent/rawgreenlet.py -> build/lib.linux-i686-2.6/gevent
copying gevent/thread.py -> build/lib.linux-i686-2.6/gevent
copying gevent/greenlet.py -> build/lib.linux-i686-2.6/gevent
copying gevent/event.py -> build/lib.linux-i686-2.6/gevent
copying gevent/hub.py -> build/lib.linux-i686-2.6/gevent
copying gevent/util.py -> build/lib.linux-i686-2.6/gevent
copying gevent/monkey.py -> build/lib.linux-i686-2.6/gevent
copying gevent/__init__.py -> build/lib.linux-i686-2.6/gevent
copying gevent/coros.py -> build/lib.linux-i686-2.6/gevent
copying gevent/select.py -> build/lib.linux-i686-2.6/gevent
copying gevent/wsgi.py -> build/lib.linux-i686-2.6/gevent
copying gevent/socket.py -> build/lib.linux-i686-2.6/gevent
copying gevent/queue.py -> build/lib.linux-i686-2.6/gevent
copying gevent/pool.py -> build/lib.linux-i686-2.6/gevent
copying gevent/timeout.py -> build/lib.linux-i686-2.6/gevent
copying gevent/backdoor.py -> build/lib.linux-i686-2.6/gevent
copying gevent/proc.py -> build/lib.linux-i686-2.6/gevent
running build_ext
building 'gevent.core' extension
creating build/temp.linux-i686-2.6
creating build/temp.linux-i686-2.6/gevent
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/python2.6 -c gevent/core.c -o build/temp.linux-i686-2.6/gevent/core.o
gevent/core.c: In function ‘__pyx_pf_6gevent_4core_get_header_version’:
gevent/core.c:4360: warning: label ‘__pyx_L1_error’ defined but not used
gevent/core.c: In function ‘__pyx_pf_6gevent_4core_reinit’:
gevent/core.c:4419: warning: label ‘__pyx_L1_error’ defined but not used
gcc -pthread -shared build/temp.linux-i686-2.6/gevent/core.o -levent -o build/lib.linux-i686-2.6/gevent/core.so
(env)[root@test1:downloads/gevent-0.10.0]# python setup.py install (02-20 16:01)
found system libevent for linux2
running install
running build
running build_py
running build_ext
running install_lib
creating /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/rawgreenlet.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/thread.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/greenlet.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/event.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/hub.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/util.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/monkey.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/__init__.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/coros.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/select.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/wsgi.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/socket.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/queue.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/pool.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/timeout.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/backdoor.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/proc.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/core.so -> /ews/test_project/env/lib/python2.6/site-packages/gevent
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/rawgreenlet.py to rawgreenlet.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/thread.py to thread.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/greenlet.py to greenlet.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/event.py to event.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/hub.py to hub.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/util.py to util.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/monkey.py to monkey.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/__init__.py to __init__.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/coros.py to coros.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/select.py to select.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/wsgi.py to wsgi.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/socket.py to socket.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/queue.py to queue.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/pool.py to pool.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/timeout.py to timeout.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/backdoor.py to backdoor.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/proc.py to proc.pyc
running install_egg_info
Writing /ews/test_project/env/lib/python2.6/site-packages/gevent-0.10.0-py2.6.egg-info
(env)[root@test1:downloads/gevent-0.10.0]# python (02-20 16:01)
Python 2.6.2 (r262:71600, Aug 5 2009, 10:31:21)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] 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 "gevent/__init__.py", line 28, in <module>
from gevent.greenlet import Greenlet, joinall, killall
File "gevent/greenlet.py", line 5, in <module>
from gevent import core
ImportError: cannot import name core
>>>
I'm attempting to use the gevent library in a Python app I'm writing. However, both easy_install and installing it manually appears to be failing. Any suggestions?
Python 2.6.2 (r262:71600, Aug 5 2009, 10:31:21)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] 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 "gevent/__init__.py", line 28, in <module>
from gevent.greenlet import Greenlet, joinall, killall
File "gevent/greenlet.py", line 5, in <module>
from gevent import core
ImportError: cannot import name core
>>>
The complete dump of my "build" and "install" commands are:
(env)[root@test1:downloads/gevent-0.10.0]# python setup.py build (02-20 16:00)
found system libevent for linux2
running build
running build_py
creating build/lib.linux-i686-2.6
creating build/lib.linux-i686-2.6/gevent
copying gevent/rawgreenlet.py -> build/lib.linux-i686-2.6/gevent
copying gevent/thread.py -> build/lib.linux-i686-2.6/gevent
copying gevent/greenlet.py -> build/lib.linux-i686-2.6/gevent
copying gevent/event.py -> build/lib.linux-i686-2.6/gevent
copying gevent/hub.py -> build/lib.linux-i686-2.6/gevent
copying gevent/util.py -> build/lib.linux-i686-2.6/gevent
copying gevent/monkey.py -> build/lib.linux-i686-2.6/gevent
copying gevent/__init__.py -> build/lib.linux-i686-2.6/gevent
copying gevent/coros.py -> build/lib.linux-i686-2.6/gevent
copying gevent/select.py -> build/lib.linux-i686-2.6/gevent
copying gevent/wsgi.py -> build/lib.linux-i686-2.6/gevent
copying gevent/socket.py -> build/lib.linux-i686-2.6/gevent
copying gevent/queue.py -> build/lib.linux-i686-2.6/gevent
copying gevent/pool.py -> build/lib.linux-i686-2.6/gevent
copying gevent/timeout.py -> build/lib.linux-i686-2.6/gevent
copying gevent/backdoor.py -> build/lib.linux-i686-2.6/gevent
copying gevent/proc.py -> build/lib.linux-i686-2.6/gevent
running build_ext
building 'gevent.core' extension
creating build/temp.linux-i686-2.6
creating build/temp.linux-i686-2.6/gevent
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/python2.6 -c gevent/core.c -o build/temp.linux-i686-2.6/gevent/core.o
gevent/core.c: In function ‘__pyx_pf_6gevent_4core_get_header_version’:
gevent/core.c:4360: warning: label ‘__pyx_L1_error’ defined but not used
gevent/core.c: In function ‘__pyx_pf_6gevent_4core_reinit’:
gevent/core.c:4419: warning: label ‘__pyx_L1_error’ defined but not used
gcc -pthread -shared build/temp.linux-i686-2.6/gevent/core.o -levent -o build/lib.linux-i686-2.6/gevent/core.so
(env)[root@test1:downloads/gevent-0.10.0]# python setup.py install (02-20 16:01)
found system libevent for linux2
running install
running build
running build_py
running build_ext
running install_lib
creating /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/rawgreenlet.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/thread.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/greenlet.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/event.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/hub.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/util.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/monkey.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/__init__.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/coros.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/select.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/wsgi.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/socket.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/queue.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/pool.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/timeout.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/backdoor.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/proc.py -> /ews/test_project/env/lib/python2.6/site-packages/gevent
copying build/lib.linux-i686-2.6/gevent/core.so -> /ews/test_project/env/lib/python2.6/site-packages/gevent
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/rawgreenlet.py to rawgreenlet.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/thread.py to thread.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/greenlet.py to greenlet.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/event.py to event.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/hub.py to hub.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/util.py to util.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/monkey.py to monkey.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/__init__.py to __init__.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/coros.py to coros.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/select.py to select.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/wsgi.py to wsgi.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/socket.py to socket.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/queue.py to queue.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/pool.py to pool.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/timeout.py to timeout.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/backdoor.py to backdoor.pyc
byte-compiling /ews/test_project/env/lib/python2.6/site-packages/gevent/proc.py to proc.pyc
running install_egg_info
Writing /ews/test_project/env/lib/python2.6/site-packages/gevent-0.10.0-py2.6.egg-info
(env)[root@test1:downloads/gevent-0.10.0]# python (02-20 16:01)
Python 2.6.2 (r262:71600, Aug 5 2009, 10:31:21)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] 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 "gevent/__init__.py", line 28, in <module>
from gevent.greenlet import Greenlet, joinall, killall
File "gevent/greenlet.py", line 5, in <module>
from gevent import core
ImportError: cannot import name core
>>>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该错误只是由于尝试从项目源目录运行脚本而引起的。更改为任何其他目录并执行“导入”效果很好。有关 gevent 邮件列表的更多信息请参见此处。
The error was caused simply by trying to run a script from the project source directory. Changing to any other directory and doing an "import" worked fine. More information here on the gevent mailing list.
我已在邮件列表中回答了您的问题。
顺便说一句,你使用的是 0.10.0 版本的 gevent 吗?这是古老的!最新的是 0.12.0。
I've answered your question on the mailing list.
BTW, are you using version 0.10.0 of gevent? It's ancient! The latest one is 0.12.0.