How to Install Cython in Python
The Cython compiler for writing C extensions in the Python language.
pip install Cython
What is Cython?
The Cython compiler for writing C extensions in the Python language.
The Cython language makes writing C extensions for the Python language as easy as Python itself. Cython is a source code translator based on Pyrex, but supports more cutting edge functionality and optimizations.
The Cython language is a superset of the Python language (almost all Python code is also valid Cython code), but Cython additionally supports optional static typing to natively call C functions, operate with C++ classes and declare fast C types on variables and class attributes. This allows the compiler to generate very efficient C code from Cython code.
This makes Cython the ideal language for writing glue code for external C/C++ libraries, and for fast C modules that speed up the execution of Python code.
Quick Start
Minimal example to get started with Cython:
import cython
print(cython.__version__)
Installation
pip (standard)
pip install Cython
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install Cython
pip3
pip3 install Cython
conda
conda install -c conda-forge Cython
Poetry
poetry add Cython
Verify the Installation
After installing, confirm the package is available:
python -c "import cython; print(cython.__version__)"
If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.
Installation Errors
Common errors when installing Cython with pip.
ModuleNotFoundError: No module named 'cython'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install Cython. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'cython' (installed but still failing)
Cause: pip installed the package into a different Python than the one running your script.
Fix: Use python -m pip install Cython to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'cython'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show Cython and upgrade with pip install --upgrade Cython.
pip: command not found
Cause: pip is not in PATH or Python was not added to PATH during installation.
Fix: Try python -m pip install Cython. On macOS/Linux try pip3.
PermissionError: [Errno 13] Permission denied
Cause: No write access to the system Python package directory.
Fix: Use a virtual environment, or add --user: pip install --user Cython
SSL: CERTIFICATE_VERIFY_FAILED
Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.
Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org Cython
Recent Releases
| Version | Released |
|---|---|
3.2.4 latest |
2026-01-04 |
3.1.8 |
2026-01-03 |
3.2.3 |
2025-12-14 |
3.2.2 |
2025-11-30 |
3.1.7 |
2025-11-12 |
Manage Cython
Upgrade to latest version
pip install --upgrade Cython
Install a specific version
pip install Cython==3.2.4
Uninstall
pip uninstall Cython
Check what is installed
pip show Cython