{"record":{"id":"848ce9bae5633dbb","repo":"apache/beam","slug":"the-apache-beam-sdk-for-python-is-only-supported-on-python-3","errorCode":null,"errorMessage":"The Apache Beam SDK for Python is only supported on Python 3. It is not supported on Python [str(sys.version_info)].","messagePattern":"The Apache Beam SDK for Python is only supported on Python 3\\. It is not supported on Python \\[str\\(sys\\.version_info\\)\\]\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"sdks/python/apache_beam/__init__.py","lineNumber":80,"sourceCode":"--------\nThe `examples subdirectory\n<https://github.com/apache/beam/tree/master/sdks/python/apache_beam/examples>`_\nhas some examples.\n\n\"\"\"\n\nimport sys\nimport warnings\n\nif sys.version_info.major == 3:\n  if sys.version_info.minor <= 9 or sys.version_info.minor >= 15:\n    warnings.warn(\n        'This version of Apache Beam has not been sufficiently tested on '\n        'Python %s.%s. You may encounter bugs or missing features.' %\n        (sys.version_info.major, sys.version_info.minor))\n  pass\nelse:\n  raise RuntimeError(\n      'The Apache Beam SDK for Python is only supported on Python 3. '\n      'It is not supported on Python [' + str(sys.version_info) + '].')\n\n# pylint: disable=wrong-import-position\nimport apache_beam.internal.pickler\nfrom apache_beam import coders\nfrom apache_beam import io\nfrom apache_beam import metrics\nfrom apache_beam import typehints\nfrom apache_beam import version\nfrom apache_beam.pipeline import *\nfrom apache_beam.pvalue import PCollection\nfrom apache_beam.pvalue import Row\nfrom apache_beam.pvalue import TaggedOutput\nfrom apache_beam.transforms import *\n\ntry:\n  # Add mitigation for CVE-2023-47248 while Beam allows affected versions","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/__init__.py#L62-L98","documentation":"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.","triggerScenarios":"Running `import apache_beam` or any Beam pipeline (python script, pytest, airflow DAG) with a Python 2 interpreter.","commonSituations":"Legacy systems whose default `python` is Python 2.7; CI images with an old interpreter on PATH; virtualenvs created with python2.","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."],"exampleFix":"// before\npython pipeline.py  # python -> Python 2.7\n// after\npython3 pipeline.py","handlingStrategy":"validation","validationCode":"import sys\nassert sys.version_info >= (3, 0), 'Apache Beam requires Python 3'","typeGuard":null,"tryCatchPattern":"try:\n    import apache_beam\nexcept RuntimeError as e:\n    sys.exit('Re-run with python3: ' + str(e))","preventionTips":["Create virtualenvs with python3 explicitly.","Pin python_version in CI and shebang lines to python3."],"tags":["python","python2","import","version-check"],"backgroundTag":"unsupported-platform","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}