To use Cython two things are needed.The Cython package itself, which contains the cython
source-to-source compiler and Cython interfaces to several C and Python libraries (for example numpy). To compile the C code generated by the cython
compiler, a C compiler is needed.
Cython can be installed with several system agnostic package management systems. These include:
PyPI via pip or easy_install:
$ pip install cython
$ easy_install cython
anaconda using conda:
$ conda install cython
Enthought canopy using the enpkg package manager:
$ enpkg cython
Also the source code can be downloaded from github and installed manually using:
$ python setup.py install
For Ubuntu the packages cython
and cython3
are available. Note that these provide an older version than the installation options mentioned above.
$ apt-get install cython cython3
For Windows, a .whl file that can be installed using pip is provided by a third party. Details on installing a .whl file on Windows can be found here.
To compile the C files generated by Cython, a compiler for C and C++ is needed. The gcc compiler is recommended and can be installed as follows.
The build-essential
package contains everything that is needed. It can be installed from the repositories using:
$ sudo apt-get install build-essential
The XCode developer tools contain a gcc like compiler.
MinGW (Minimalist GNU for Windows) contains a Windows version of gcc. The compiler from Visual Studio can also be used.