{"record":{"id":"d2d16c4e41883f2a","repo":"apache/beam","slug":"error-upgrading-pip","errorCode":null,"errorMessage":"error upgrading pip","messagePattern":"error upgrading pip","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go","lineNumber":467,"sourceCode":"\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 {\n\t\t\treturn \"\", errors.Wrap(err, \"error creating new virtual environment for python expansion service\")\n\t\t}\n\t\terr = exec.Command(venvPython, \"-m\", \"pip\", \"install\", \"--upgrade\", \"pip\").Run()\n\t\tif err != nil {\n\t\t\treturn \"\", errors.Wrap(err, \"error upgrading pip\")\n\t\t}\n\t\terr = exec.Command(venvPython, \"-m\", \"pip\", \"install\", \"--upgrade\", \"setuptools\").Run()\n\t\tif err != nil {\n\t\t\treturn \"\", errors.Wrap(err, \"error upgrading setuptools\")\n\t\t}\n\t\terr = exec.Command(venvPython, \"-m\", \"pip\", \"install\", beamPackage, \"pyparsing==2.4.2\").Run()\n\t\tif err != nil {\n\t\t\treturn \"\", errors.Wrap(err, fmt.Sprintf(\"error installing beam package: %v\", beamPackage))\n\t\t}\n\t\tif len(extraPackages) > 0 {\n\t\t\tcmd := []string{\"-m\", \"pip\", \"install\"}\n\t\t\tcmd = append(cmd, extraPackages...)\n\t\t\terr = exec.Command(venvPython, cmd...).Run()\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", errors.Wrap(err, \"error installing dependencies\")\n\t\t\t}\n\t\t}\n\t\terr = exec.Command(venvPython, \"-c\", \"import apache_beam\").Run()","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go#L449-L485","documentation":"Raised in expansionx.SetUpPythonEnvironment when `pip install --upgrade pip` fails inside the freshly created virtualenv for the Python expansion service. The venv itself was created, but bootstrap of the package tooling failed.","triggerScenarios":"startPythonExpansionService -> SetUpPythonEnvironment where the venv's pip upgrade step returns non-zero: no network access to PyPI, missing ensurepip in the venv, or SSL/proxy issues.","commonSituations":"Corporate proxies/firewalls blocking pypi.org; venv created without pip (python -m venv --without-pip or missing ensurepip); old Python whose bundled pip can't negotiate TLS.","solutions":["Ensure outbound network/HTTPS access to pypi.org from the machine (configure HTTPS_PROXY if needed)","Create the venv with pip support (ensure ensurepip is installed for the interpreter)","Retry after cleaning the cache; run the same pip upgrade command manually to see the real error","Use a newer Python interpreter (3.7+) whose bundled pip supports current PyPI TLS"],"exampleFix":"// before\n// pip install --upgrade pip fails behind proxy\n// after\nexport HTTPS_PROXY=http://proxy.corp:8080\n./venv/bin/python -m pip install --upgrade pip  # verify manually","handlingStrategy":"validation","validationCode":"if err := exec.Command(\"curl\", \"-sSf\", \"https://pypi.org/simple/\", \"-o\", \"/dev/null\").Run(); err != nil {\n    return fmt.Errorf(\"PyPI unreachable; configure proxy before starting expansion service\")\n}","typeGuard":null,"tryCatchPattern":"python, err := expansionx.SetUpPythonEnvironment(ctx, py, pkg, extras)\nif err != nil && strings.Contains(err.Error(), \"error upgrading pip\") {\n    return fmt.Errorf(\"set HTTPS_PROXY/HTTPS_PROXY and ensure ensurepip is installed: %w\", err)\n}","preventionTips":["Configure HTTPS_PROXY/PIP_INDEX_URL for corporate networks","Use a Python build that ships ensurepip","Verify pip upgrade works in a scratch venv before running pipelines"],"tags":["python","pip","virtualenv","network"],"backgroundTag":"api-request-failed","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"}