{"record":{"id":"85fa13eacbaffb0b","repo":"apache/beam","slug":"no-python-installation-found-v","errorCode":null,"errorMessage":"no python installation found: %v","messagePattern":"no python installation found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go","lineNumber":444,"sourceCode":"\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)\n\tbeamPackage := fmt.Sprintf(\"apache_beam[gcp,aws,azure,dataframe]==%s\", core.SdkVersion)\n\tvenvDir := filepath.Join(\n\t\tcacheDir, \"venvs\",\n\t\tfmt.Sprintf(\"py-%s-beam-%s-%s\", py, core.SdkVersion, strings.Join(extraPackages, \";\")),\n\t)\n\tvenvPython := filepath.Join(venvDir, \"bin\", \"python\")\n\n\tif _, err := os.Stat(venvPython); err != nil {\n\t\terr := exec.Command(py, \"-m\", \"venv\", venvDir).Run()\n\t\tif err != nil {","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go#L426-L462","documentation":"SetUpPythonEnvironment prepares a virtualenv for the Apache Beam Python SDK to run an expansion service module. It first calls GetPythonVersion() to locate a usable python3 executable; if that fails, it wraps the failure with \"no python installation found\". This surfaces environment problems early instead of failing later when launching the Python expansion service.","triggerScenarios":"Calling SetUpPythonEnvironment (directly or via startPythonExpansionService) on a machine where no python3 binary is on PATH, where the found python is too old, or where GetPythonVersion's exec of `python3 --version` errors.","commonSituations":"CI containers without Python installed; PATH not including the Python install directory; minimal Docker images (e.g. distroless); users with only `python` (2.x) and no `python3`.","solutions":["Install Python 3 and ensure the `python3` executable is on PATH (e.g. apt-get install python3 / brew install python).","Verify with `python3 --version` in the same environment/shell the Go job runs in.","If Python exists under a nonstandard path, extend PATH before starting the pipeline.","For containers, use a base image that includes Python 3 or install it in the Dockerfile."],"exampleFix":"// before\nrunner, err := expansionx.SetUpPythonEnvironment(extraPackage)\n// after (pre-check in caller)\nif _, err := exec.LookPath(\"python3\"); err != nil {\n    return fmt.Errorf(\"python3 must be installed and on PATH before starting python expansion service: %w\", err)\n}\nrunner, err := expansionx.SetUpPythonEnvironment(extraPackage)","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"python3\"); err != nil {\n    return fmt.Errorf(\"python3 not found on PATH: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"runner, err := expansionx.SetUpPythonEnvironment(extra)\nif err != nil {\n    if strings.Contains(err.Error(), \"no python installation found\") {\n        return fmt.Errorf(\"install Python 3 and add it to PATH: %w\", err)\n    }\n    return err\n}","preventionTips":["Bake python3 into CI/Docker images used for Beam pipelines","Check exec.LookPath(\"python3\") at pipeline startup","Document Python 3 as a prerequisite for Python expansion services"],"tags":["go","python","environment","expansion-service"],"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"}