Skip to main content

Coroutine-based network library

Project description


gevent is a coroutine -based Python networking library that uses greenlet to provide a high-level synchronous API on top of the libev or libuv event loop.

Features include:

gevent is inspired by eventlet but features a more consistent API, simpler implementation and better performance. Read why others use gevent and check out the list of the open source projects based on gevent.

gevent was written by Denis Bilenko.

Since version 1.1, gevent is maintained by Jason Madden for NextThought with help from the contributors and is licensed under the MIT license.

See what’s new in the latest major release.

Check out the detailed changelog for this version.

Read the documentation online at

Post feedback and issues on the bug tracker, mailing list, blog and twitter (@gevent).

Installation and Requirements

Supported Platforms

gevent 1.3 runs on Python 2.7 and Python 3. Releases 3.4, 3.5 and 3.6 of Python 3 are supported. (Users of older versions of Python 2 need to install gevent 1.0.x (2.5), 1.1.x (2.6) or 1.2.x (<=2.7.8); gevent 1.2 can be installed on Python 3.3.) gevent requires the greenlet library and will install the cffi library by default on Windows.

gevent 1.3 also runs on PyPy 5.5 and above, although 5.9 or above is strongly recommended. On PyPy, there are no external dependencies.

gevent is tested on Windows, OS X, and Linux, and should run on most other Unix-like operating systems (e.g., FreeBSD, Solaris, etc.)


gevent and greenlet can both be installed with pip, e.g., pip install gevent. Installation using buildout is also supported.

On Windows, OS X, and Linux, both gevent and greenlet are distributed as binary wheels.

Installing From Source

If you are unable to use the binary wheels (for platforms where no pre-built wheels are available or if wheel installation is disabled, e.g., for libuv support on Linux), here are some things you need to know.

  • You can install gevent from source with pip install --no-binary gevent gevent.

  • You’ll need a working C compiler that can build Python extensions. On some platforms, you may need to install Python development packages.

  • Installing from source requires setuptools. This is installed automatically in virtual environments and by buildout. However, gevent uses PEP 496 environment markers in Consequently, you’ll need a version of setuptools newer than 25 (mid 2016) to install gevent from source; a version that’s too old will produce a ValueError. Older versions of pipenv may also have issues installing gevent for this reason.

  • To build the libuv backend (which is required on Windows and optional elsewhere), or the CFFI-based libev backend, you must install cffi before attempting to install gevent on CPython (on PyPy this step is not necessary).

Common Installation Issues

The following are some common installation problems and solutions for those compiling gevent from source.

  • Some Linux distributions are now mounting their temporary directories with the noexec option. This can cause a standard pip install gevent to fail with an error like cannot run C compiled programs. One fix is to mount the temporary directory without that option. Another may be to use the --build option to pip install to specify another directory. See issue #570 and issue #612 for examples.

  • Also check for conflicts with environment variables like CFLAGS. For example, see Library Updates.

  • Users of a recent SmartOS release may need to customize the CPPFLAGS (the environment variable containing the default options for the C preprocessor) if they are using the libev shipped with gevent. See Operating Systems for more information.

  • If you see 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'"), the version of setuptools is too old. Install a more recent version of setuptools.

Extra Dependencies

gevent has no runtime dependencies outside the standard library, greenlet and (on some platforms) cffi. However, there are a number of additional libraries that extend gevent’s functionality and will be used if they are available.

The psutil library is needed to monitor memory usage.

zope.event is highly recommended for configurable event support; it can be installed with the events extra, e.g., pip install gevent[events].

dnspython is required for the new pure-Python resolver, and on Python 2, so is idna. They can be installed with the dnspython extra.


To install the latest development version:

pip install setuptools cffi 'cython>=0.28' git+git://

To hack on gevent (using a virtualenv):

$ git clone
$ cd gevent
$ virtualenv env
$ source env/bin/activate
(env) $ pip install -r dev-requirements.txt

Running Tests

There are a few different ways to run the tests. To simply run the tests on one version of Python during development, begin with the above instructions to install gevent in a virtual environment and then run:

(env) $ cd src/greentest
(env) $ python ./

Before submitting a pull request, it’s a good idea to run the tests across all supported versions of Python, and to check the code quality using prospector. This is what is done on Travis CI. Locally it can be done using tox:

pip install tox

The testrunner accepts a --coverage argument to enable code coverage metrics through the package. That would go something like this:

cd src/greentest
python --coverage
coverage combine
coverage html -i
<open htmlcov/index.html>

Continuous integration

A test suite is run for every push and pull request submitted. Travis CI is used to test on Linux, and AppVeyor runs the builds on Windows.

Builds on Travis CI automatically submit updates to to monitor test coverage.

Project details

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gevent-1.3.6.tar.gz (4.5 MB view hashes)

Uploaded Source

Built Distributions

gevent-1.3.6-pp260-pypy_41-macosx_10_13_x86_64.whl (696.4 kB view hashes)

Uploaded PyPy macOS 10.13+ x86-64

gevent-1.3.6-pp259-pypy_41-win32.whl (671.6 kB view hashes)

Uploaded PyPy Windows x86

gevent-1.3.6-cp37-cp37m-win_amd64.whl (2.1 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

gevent-1.3.6-cp37-cp37m-manylinux1_x86_64.whl (4.5 MB view hashes)

Uploaded CPython 3.7m

gevent-1.3.6-cp37-cp37m-macosx_10_9_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

gevent-1.3.6-cp36-cp36m-win_amd64.whl (2.1 MB view hashes)

Uploaded CPython 3.6m Windows x86-64

gevent-1.3.6-cp36-cp36m-win32.whl (1.9 MB view hashes)

Uploaded CPython 3.6m Windows x86

gevent-1.3.6-cp36-cp36m-manylinux1_x86_64.whl (4.5 MB view hashes)

Uploaded CPython 3.6m

gevent-1.3.6-cp36-cp36m-macosx_10_6_intel.whl (3.1 MB view hashes)

Uploaded CPython 3.6m macOS 10.6+ intel

gevent-1.3.6-cp35-cp35m-win_amd64.whl (2.1 MB view hashes)

Uploaded CPython 3.5m Windows x86-64

gevent-1.3.6-cp35-cp35m-win32.whl (1.9 MB view hashes)

Uploaded CPython 3.5m Windows x86

gevent-1.3.6-cp35-cp35m-manylinux1_x86_64.whl (4.4 MB view hashes)

Uploaded CPython 3.5m

gevent-1.3.6-cp35-cp35m-macosx_10_6_intel.whl (3.1 MB view hashes)

Uploaded CPython 3.5m macOS 10.6+ intel

gevent-1.3.6-cp34-cp34m-win_amd64.whl (2.1 MB view hashes)

Uploaded CPython 3.4m Windows x86-64

gevent-1.3.6-cp34-cp34m-win32.whl (2.0 MB view hashes)

Uploaded CPython 3.4m Windows x86

gevent-1.3.6-cp34-cp34m-manylinux1_x86_64.whl (4.5 MB view hashes)

Uploaded CPython 3.4m

gevent-1.3.6-cp34-cp34m-macosx_10_6_intel.whl (3.1 MB view hashes)

Uploaded CPython 3.4m macOS 10.6+ intel

gevent-1.3.6-cp27-cp27mu-manylinux1_x86_64.whl (4.2 MB view hashes)

Uploaded CPython 2.7mu

gevent-1.3.6-cp27-cp27m-win_amd64.whl (2.1 MB view hashes)

Uploaded CPython 2.7m Windows x86-64

gevent-1.3.6-cp27-cp27m-win32.whl (2.0 MB view hashes)

Uploaded CPython 2.7m Windows x86

gevent-1.3.6-cp27-cp27m-manylinux1_x86_64.whl (4.2 MB view hashes)

Uploaded CPython 2.7m

gevent-1.3.6-cp27-cp27m-macosx_10_9_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 2.7m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page