Installing Cython — Cython 3.1.0rc1 documentation (original) (raw)

Many scientific Python distributions, such as Anaconda [Anaconda], Enthought Canopy [Canopy], and Sage [Sage], bundle Cython and no setup is needed. Note however that if your distribution ships a version of Cython which is too old you can still use the instructions below to update Cython.

Unlike most Python software, Cython requires a C compiler to be present on the system. The details of getting a C compiler varies according to the system used:

The simplest way of installing Cython is by using pip:

On platforms that are covered by one of the binary wheel packages provided on PyPI, this will install an accelerated wheel which contains some Cython compiled modules. Other platforms will use pure Python wheels that install quickly but run somewhat slower, which is still well adapted for one-time builds e.g. in CI build servers.

For installations on systems where Cython is executed a lot, it is worth checking that the installation uses a binary module, or otherwise to build a binary wheel locally.

The newest Cython release can always be downloaded fromhttps://cython.org/. Unpack the tarball or zip file, enter the directory, and then run:

For one-time installations from a Cython source checkout, it is substantially faster than a full binary build to just install the uncompiled (slower) version of Cython with something like

NO_CYTHON_COMPILE=true pip install .

[Sage]

  1. Stein et al., Sage Mathematics Software, https://www.sagemath.org/