apache/beam · critical · RuntimeError
The Apache Beam SDK for Python is only supported on Python…
Error message
The Apache Beam SDK for Python is only supported on Python 3. It is not supported on Python [str(sys.version_info)].
What it means
Startup guard in the apache_beam package __init__: the Python SDK only supports Python 3, so importing apache_beam under Python 2 raises this RuntimeError immediately. It fires at import time, before any Beam code runs, whenever the interpreter's sys.version_info.major is not 3.
Solutions
- Run with Python 3: `python3 your_pipeline.py` or `python3 -m pip install apache-beam` in a py3 venv.
- Recreate the virtualenv with `python3 -m venv env` and reinstall dependencies.
- Pin the interpreter in CI/airflow (e.g. `python_version: 3.x`) so `python` resolves to Python 3.
Example fix
// before python pipeline.py # python -> Python 2.7 // after python3 pipeline.py
Defensive patterns
Strategy: validation
Validate before calling
import sys assert sys.version_info >= (3, 0), 'Apache Beam requires Python 3'
Try / catch
try:
import apache_beam
except RuntimeError as e:
sys.exit('Re-run with python3: ' + str(e)) Prevention
- Create virtualenvs with python3 explicitly.
- Pin python_version in CI and shebang lines to python3.
When it happens
Trigger: Running `import apache_beam` or any Beam pipeline (python script, pytest, airflow DAG) with a Python 2 interpreter.
Common situations: Legacy systems whose default `python` is Python 2.7; CI images with an old interpreter on PATH; virtualenvs created with python2.
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
- Could not import joblib in this execution environment. For…
- google-cloud-bigquery-storage is required for…
- was not imported correctly, have you used an `import`…
- This version of Apache Beam has not been sufficiently…
- You are using version
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/848ce9bae5633dbb.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/__init__.py:80
--------
The `examples subdirectory
<https://github.com/apache/beam/tree/master/sdks/python/apache_beam/examples>`_
has some examples.
"""
import sys
import warnings
if sys.version_info.major == 3:
if sys.version_info.minor <= 9 or sys.version_info.minor >= 15:
warnings.warn(
'This version of Apache Beam has not been sufficiently tested on '
'Python %s.%s. You may encounter bugs or missing features.' %
(sys.version_info.major, sys.version_info.minor))
pass
else:
raise RuntimeError(
'The Apache Beam SDK for Python is only supported on Python 3. '
'It is not supported on Python [' + str(sys.version_info) + '].')
# pylint: disable=wrong-import-position
import apache_beam.internal.pickler
from apache_beam import coders
from apache_beam import io
from apache_beam import metrics
from apache_beam import typehints
from apache_beam import version
from apache_beam.pipeline import *
from apache_beam.pvalue import PCollection
from apache_beam.pvalue import Row
from apache_beam.pvalue import TaggedOutput
from apache_beam.transforms import *
try:
# Add mitigation for CVE-2023-47248 while Beam allows affected versionsView on GitHub (pinned to 12126d8942)