gevent 在 Ubuntu 上无法正确安装

发布于 11-16 15:46 字数 519 浏览 3 评论 0原文

我想尝试 gevent,但安装后我无法加载任何 gevent 模块。

安装步骤为:

sudo apt-get install libevent-dev
sudo pip install greenlet
sudo pip install gevent

环境设置为Ubuntu 10.10 x86_64 GNU/Linux。

当我尝试进行简单测试时,我得到:

>>> import gevent
>>> from gevent import socket
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name socket

我怀疑安装没有执行应有的操作,但我不确定出了什么问题。

I want to experiment with gevent, but after installing it I can't load any gevent module.

The installation steps are:

sudo apt-get install libevent-dev
sudo pip install greenlet
sudo pip install gevent

The environment setup is Ubuntu 10.10 x86_64 GNU/Linux.

When I try to do a simple test, I get:

>>> import gevent
>>> from gevent import socket
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name socket

I suspect the installation not doing what it should, but I'm not sure what wrong.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

橘虞初梦2024-11-23 15:46:15

在使用 python 2.6 的 Ubuntu 10.04 上,我必须这样做:

apt-get install libevent-dev
apt-get install python-all-dev
easy_install greenlet
easy_install gevent 

顺便说一句,关于 Gevent 的很好的教程: http:// sdiehl.github.com/gevent-tutorial/

On Ubuntu 10.04 with python 2.6 I had to do:

apt-get install libevent-dev
apt-get install python-all-dev
easy_install greenlet
easy_install gevent 

By the way, nice tutorial on Gevent: http://sdiehl.github.com/gevent-tutorial/

清君侧2024-11-23 15:46:15

在 Ubuntu 10.10(及更高版本)中,gevent(和依赖项)打包在 Ubuntu 存储库中。

11.04 日:

$ sudo apt-get install python-gevent
...
$ python
corey@lenovo:~$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gevent
>>> from gevent import socket
>>> print gevent.__version__
0.13.0

In Ubuntu 10.10 (and later), gevent (and dependencies) is packaged in the Ubuntu repositories.

on 11.04:

$ sudo apt-get install python-gevent
...
$ python
corey@lenovo:~$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gevent
>>> from gevent import socket
>>> print gevent.__version__
0.13.0
醉梦枕江山2024-11-23 15:46:15

我成功地使用 pip 以“python 方式”安装。这就是我所做的:

我在某处读到 Ubuntu 的设置工具似乎已损坏。当你想安装一个包时,它会报告

用户警告:安装工具未构建鸡蛋[未知版本] (/usr/lib/python2.6/dist-packages)

这些命令修复安装工具:

sudo rm -rf /usr/lib/python2.6/dist-packages/setuptools.egg-info/
sudo apt-get install --reinstall python-setuptools

在此之后,我尝试使用 pip 重新安装这两个包--升级参数。它没有帮助,但我尝试了 easy_install 并且它有效。我在 pip 之前尝试过,但是损坏的设置工具阻止了它工作。

sudo easy_install greenlet
sudo easy_install gevent

好了,最新版本(目前为 0.13.6)。

I managed to succeed to install in a "python way" using pip. Here is what I did:

I read somewhere that it seems like Ubuntu's setup tools are broken. When you want to install a package, it reports

UserWarning: Unbuilt egg for setuptools [unknown version] (/usr/lib/python2.6/dist-packages)

These commands repare the setup tools:

sudo rm -rf /usr/lib/python2.6/dist-packages/setuptools.egg-info/
sudo apt-get install --reinstall python-setuptools

After this, I tried to reinstall the two packages with pip's --upgrade argument. It didn't help, but I tried easy_install and it worked. I had tried it before pip, but the broken setup tools prevented it from working.

sudo easy_install greenlet
sudo easy_install gevent

There you go, with the latest version (0.13.6 as of now).

飘过的浮云2024-11-23 15:46:15

尝试了 zzart 发布的内容,但在 Ubuntu Trusty Tahr (14.04) 上仍然出现错误:

File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2583, in scan_list
    "Expected ',' or end-of-list in",line,"at",line[p:]
ValueError: ("Expected ',' or end-of-list in", "cffi >= 1.11.5 ; sys_platform == 'win32' and platform_python_implementation == 'CPython'", 'at', " ; sys_platform == 'win32' and platform_python_implementation == 'CPython'")

这修复了它:

sudo pip install --upgrade setuptools pip
sudo easy_install gevent

Tried what zzart posted, but still got an error on Ubuntu Trusty Tahr (14.04):

File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2583, in scan_list
    "Expected ',' or end-of-list in",line,"at",line[p:]
ValueError: ("Expected ',' or end-of-list in", "cffi >= 1.11.5 ; sys_platform == 'win32' and platform_python_implementation == 'CPython'", 'at', " ; sys_platform == 'win32' and platform_python_implementation == 'CPython'")

This fixed it:

sudo pip install --upgrade setuptools pip
sudo easy_install gevent
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文