安装libevent;
安装greenlet: sudo easy_install gevent (need net access)
bingo!
-> python-dev -> libpython2.7
deb包下载网站 ;
sudo dpkg -i libpython2.7_2.7.2-5ubuntu1_i386.deb
2013-02-16:
Ubuntu Server 12.04上自带python 2.7,所以只要安装greenlet, libevent和gevnet就行了,
apt-get install python-pip
apt-get install python-dev(否则安装greenlet报错)
pip install greenlet
pip install gevent
验证:
将下面的代码保存为gex.py,然后用python gex.py运行得到结果,但gevent官网install上所述的repl方式执行失败,原因不明。
import gevent from gevent import socket urls = ['www.google.com', 'www.example.com', 'www.python.org'] jobs = [gevent.spawn(socket.gethostbyname, url) for url in urls] gevent.joinall(jobs, timeout=2) [job.value for job in jobs]
本地安装方式:
Ubuntu上:下载gevent-0.13.8.tar.gz和greenlet-0.4.0.zip(源码包)编译失败;
Windows上:greenlet和gevent都有安装包,但在windows上安装libevent比较难,放弃;