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

  1. Run `pip install Cython; python setup.py build_ext --inplace` in the Beam source root, then re-run the profiler.
  2. Alternatively install a compiled Beam distribution (`pip install apache-beam`) if profiling against a release.
  3. 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

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


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)