apache/beam · warning
Cython not found, cython extensions will not be generated…
Error message
Cython not found, cython extensions will not be generated. To use cythonized extensions, pip install cython and run python setup.py build_ext --inplace
What it means
When the Cython package is not importable, Beam's setup.py catches ImportError and warns that cythonized extensions will not be built. The build falls back to cythonize returning an empty list, so the install succeeds but without optimized native extensions (e.g. Cython-based coders/transforms run in slower pure-Python mode).
Solutions
- Install cython: pip install cython, then run python setup.py build_ext --inplace.
- Install numpy as well (the cythonize wrapper needs it for include dirs): pip install cython numpy.
- Prefer installing an official apache-beam wheel (pip install apache-beam) which ships pre-built extensions and skips this path entirely.
Example fix
// before $ python setup.py build_ext --inplace # cython missing // after $ pip install cython numpy $ python setup.py build_ext --inplace
Defensive patterns
Strategy: fallback
Validate before calling
import importlib.util
if importlib.util.find_spec('cython') is None or importlib.util.find_spec('numpy') is None:
print('Warning: extensions will be skipped; pip install cython numpy') Try / catch
try:
run_build()
except SystemExit:
print('Falling back to pure-Python install (slower): pip install apache-beam') Prevention
- Install build extras: pip install cython numpy before source builds
- Prefer official apache-beam wheels with prebuilt extensions
- Add a build-time assertion for cython in CI
When it happens
Trigger: Running 'python setup.py build_ext --inplace' or installing from source without the cython package installed in the build environment.
Common situations: Fresh virtualenv without dev dependencies; building Beam wheels in CI images that omit build extras; users installing from a git checkout rather than a wheel.
Understand the failure class
Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.
Related errors
- You are using version
- AWS dependencies are not installed, and no alternative…
- Azure dependencies are not installed. Unable to run.
- Bigquery dependencies are not installed.
- Bigquery dependencies are not installed.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/6c2dca949f5b2c64.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/setup.py:141
_CYTHON_VERSION, REQUIRED_CYTHON_VERSION
)
)
except PackageNotFoundError:
# do nothing if Cython is not installed
pass
try:
# pylint: disable=wrong-import-position
from Cython.Build import cythonize as cythonize0
def cythonize(*args, **kwargs):
import numpy
extensions = cythonize0(*args, **kwargs)
for e in extensions:
e.include_dirs.append(numpy.get_include())
return extensions
except ImportError:
warnings.warn(
"Cython not found, cython extensions will not be generated. " \
"To use cythonized extensions, pip install cython and run " \
"python setup.py build_ext --inplace"
)
cythonize = lambda *args, **kwargs: []
# [BEAM-8181] pyarrow cannot be installed on 32-bit Windows platforms.
if sys.platform == 'win32' and sys.maxsize <= 2**32:
pyarrow_dependency = ['']
else:
pyarrow_dependency = [
# Generally try to cover versions released in the last two years.
# Update python/sdks/tox.ini to cover the same pyarrow versions
# when updating the bounds here.
'pyarrow>=14.0.1,<26.0.0',
]
# Exclude pandas<=1.4.2 since it doesn't work with numpy 1.24.x.View on GitHub (pinned to 12126d8942)