apache/beam · error · RuntimeError
Profiling uncompiled code. To compile beam, run 'pip…
Error message
Profiling uncompiled code. To compile beam, run 'pip install Cython; python setup.py build_ext --inplace'
What it means
RuntimeError raised by `check_compiled` in apache_beam.tools.utils when the imported Beam module (e.g. a Cython-optimized module used in benchmarks) is a pure-Python `.py`/`.pyc` file rather than a compiled extension. Beam profiling tools require the compiled build for meaningful performance numbers.
Solutions
- Run `pip install Cython; python setup.py build_ext --inplace` in the Beam source root, then re-run the profiler.
- Alternatively install a compiled Beam distribution (`pip install apache-beam`) if profiling against a release.
- Verify the module file extension is no longer `.py`/`.pyc` before profiling.
Example fix
// before pip install apache-beam # pure-python, no compiled extensions // after pip install Cython python setup.py build_ext --inplace
Defensive patterns
Strategy: try-catch
Validate before calling
import importlib, os
mod = importlib.import_module(module)
if os.path.splitext(mod.__file__)[-1] in ('.py', '.pyc'):
raise SystemExit('Beam not compiled: run pip install Cython; python setup.py build_ext --inplace') Try / catch
try:
run_benchmark()
except RuntimeError as e:
if 'uncompiled code' in str(e):
os.system('pip install Cython && python setup.py build_ext --inplace') Prevention
- Build Cython extensions after every fresh source checkout
- Use release wheels for profiling when source builds aren't needed
- Check module file extension before benchmarking
When it happens
Trigger: Running Beam benchmark/profiling tools (`apache_beam.tools.*`) with a pip-installed or un-built source checkout where Cython extensions were never compiled.
Common situations: Profiling from a source clone without running `setup.py build_ext --inplace`; installing a pure-Python wheel; a dev environment missing Cython so extensions were skipped.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- Cython not found, cython extensions will not be generated…
- Failed to build package from
- not found. Please build the server with \n cd ; ./gradlew
- Unable to find the job id or job name from envvar.
- You are using version
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/175e4ba81db90f6f.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/tools/utils.py:44
import time
from typing import Callable
from typing import NamedTuple
import numpy
BenchmarkFn = Callable[[], None]
BenchmarkFactoryFn = Callable[[int], BenchmarkFn]
def check_compiled(module):
"""Check whether given module has been compiled.
Args:
module: string, module name
"""
check_module = importlib.import_module(module)
ext = os.path.splitext(check_module.__file__)[-1]
if ext in ('.py', '.pyc'):
raise RuntimeError(
"Profiling uncompiled code.\n"
"To compile beam, run "
"'pip install Cython; python setup.py build_ext --inplace'")
class BenchmarkConfig(NamedTuple):
"""
Attributes:
benchmark: a callable that takes an int argument - benchmark size,
and returns a callable. A returned callable must run the code being
benchmarked on an input of specified size.
For example, one can implement a benchmark as:
class MyBenchmark(object):
def __init__(self, size):
[do necessary initialization]
def __call__(self):View on GitHub (pinned to 12126d8942)