gevent does not install properly on Ubuntu

Question:

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.

Asked By: FabienB

||

Answers:

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
Answered By: Corey Goldberg

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).

Answered By: FabienB

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/

Answered By: zzart

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
Answered By: Sideshow Leonard
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.