{"record":{"id":"c0c213e2e5df5bd3","repo":"apache/beam","slug":"no-python-installation-found-if-you-use-a-custom-container","errorCode":null,"errorMessage":"no python installation found. If you use a custom container image, please check if python/python3 is available or specify the full path to the python interpreter in PYTHON_PATH environment variable","messagePattern":"no python installation found\\. If you use a custom container image, please check if python/python3 is available or specify the full path to the python interpreter in PYTHON_PATH environment variable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go","lineNumber":434,"sourceCode":"\t_, err := os.Stat(jarPath)\n\treturn err == nil\n}\n\n// GetPythonVersion returns the Python version to use. It checks for\n// env variable PYTHON_PATH and returns that it if set.\n// If no PYTHON_PATH is defined then it checks for python or python3\n// and returns that. Otherwise it returns an error.\nfunc GetPythonVersion() (string, error) {\n\tif pythonPath := os.Getenv(\"PYTHON_PATH\"); pythonPath != \"\" {\n\t\treturn pythonPath, nil\n\t}\n\tfor _, v := range []string{\"python\", \"python3\"} {\n\t\tcmd := exec.Command(v, \"--version\")\n\t\tif err := cmd.Run(); err == nil {\n\t\t\treturn v, nil\n\t\t}\n\t}\n\treturn \"\", errors.New(\"no python installation found. If you use a \" +\n\t\t\"custom container image, please check if python/python3 is available or specify the \" +\n\t\t\"full path to the python interpreter in PYTHON_PATH environment variable\")\n}\n\n// SetUpPythonEnvironment sets up the virtual ennvironment required for the\n// Apache Beam Python SDK to run an expansion service module.\nfunc SetUpPythonEnvironment(extraPackage string) (string, error) {\n\tpy, err := GetPythonVersion()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"no python installation found: %v\", err)\n\t}\n\textraPackages := []string{}\n\tif len(extraPackage) > 0 {\n\t\textraPackages = strings.Split(extraPackage, \" \")\n\t}\n\n\t// create python virtual environment\n\tsort.Strings(extraPackages)","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go#L416-L452","documentation":"GetPythonVersion probes for a 'python' or 'python3' executable to set up the Python expansion service environment. If neither can be executed, it fails with guidance about custom container images and the PYTHON_PATH environment variable.","triggerScenarios":"Calling GetPythonVersion (indirectly via SetUpPythonEnvironment, setupVenv, pipInstallRequirements, logRuntimeDependencies, or starting the Python expansion service) on a host or container without python/python3 on PATH.","commonSituations":"Using a custom container image that lacks a Python runtime; running Go-only jobs that trigger xlang expansion without Python installed; Python installed under a non-PATH name or custom location; slim/distroless images without python.","solutions":["Install python3 in the environment/container running the expansion service","Set PYTHON_PATH to the full path of the python interpreter (e.g. /usr/local/bin/python3)","Use a Beam SDK container image that includes Python, or base your custom image on a beam SDK image","Verify PATH inside the container: run `which python3` to confirm availability"],"exampleFix":"// before\ncmd := exec.Command(\"go\", \"run\")\n// after\nos.Setenv(\"PYTHON_PATH\", \"/usr/local/bin/python3\") // in the environment launching the expansion service\ncmd := exec.Command(\"go\", \"run\")","handlingStrategy":"validation","validationCode":"for _, v := range []string{\"python\", \"python3\", os.Getenv(\"PYTHON_PATH\")} {\n    if v == \"\" { continue }\n    if p, err := exec.LookPath(v); err == nil { pythonBin = p; break }\n}\nif pythonBin == \"\" { return errors.New(\"no python interpreter on PATH; install python3 or set PYTHON_PATH\") }","typeGuard":null,"tryCatchPattern":"ver, err := expansionx.GetPythonVersion()\nif err != nil {\n    if strings.Contains(err.Error(), \"no python installation found\") {\n        return fmt.Errorf(\"install python3 in the image or set PYTHON_PATH: %w\", err)\n    }\n    return err\n}","preventionTips":["Base custom containers on official Beam SDK images which include Python","Set PYTHON_PATH explicitly in Dockerfiles for slim images","Run `which python3` as a container smoke test","Document Python as a runtime requirement for cross-language expansion"],"tags":["go","apache-beam","python","environment","container"],"backgroundTag":"missing-env-var","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"}