{"record":{"id":"bbb6f117c0a14417","repo":"bazelbuild/bazel","slug":"bazel-does-not-support-execution-of-python-interpr","errorCode":null,"errorMessage":"Bazel does not support execution of Python interpreters via labels yet","messagePattern":"Bazel does not support execution of Python interpreters via labels yet","errorType":"panic","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"tools/python/python_bootstrap_template.txt","lineNumber":114,"sourceCode":"def FindCoverageEntryPoint(module_space):\n  cov_tool = '%coverage_tool%'\n  if cov_tool:\n    PrintVerboseCoverage('Using toolchain coverage_tool %r' % cov_tool)\n  else:\n    cov_tool = os.environ.get('PYTHON_COVERAGE')\n    if cov_tool:\n      PrintVerboseCoverage('PYTHON_COVERAGE: %r' % cov_tool)\n  if cov_tool:\n    return FindBinary(module_space, cov_tool)\n  return None\n\ndef FindBinary(module_space, bin_name):\n  \"\"\"Finds the real binary if it's not a normal absolute path.\"\"\"\n  if not bin_name:\n    return None\n  if bin_name.startswith(\"//\"):\n    # Case 1: Path is a label. Not supported yet.\n    raise AssertionError(\n        \"Bazel does not support execution of Python interpreters via labels yet\"\n    )\n  elif os.path.isabs(bin_name):\n    # Case 2: Absolute path.\n    return bin_name\n  # Use normpath() to convert slashes to os.sep on Windows.\n  elif os.sep in os.path.normpath(bin_name):\n    # Case 3: Path is relative to the repo root.\n    return os.path.join(module_space, bin_name)\n  else:\n    # Case 4: Path has to be looked up in the search path.\n    return SearchPath(bin_name)\n\ndef CreatePythonPathEntries(python_imports, module_space):\n  parts = python_imports.split(':')\n  return [module_space] + ['%s/%s' % (module_space, path) for path in parts]\n\ndef FindModuleSpace(main_rel_path):","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/tools/python/python_bootstrap_template.txt#L96-L132","documentation":"Raised in the generated Python launcher (python_bootstrap_template.txt) by FindBinary when the configured python binary path starts with '//' — i.e. someone specified the interpreter as a Bazel label. The bootstrap runs before Bazel can resolve labels to files, so label-based interpreter execution is explicitly unsupported (Case 1) and fails fast.","triggerScenarios":"Setting --python_top/--python interpreter configuration (or a rule attribute like python_interpreter) to a value like '//tools/python:py3' in a context that flows into PYTHON_BINARY for the stub script.","commonSituations":"Migrating from --python_path to label-based interpreter config too early; rules passing $(location //...) style values into the interpreter field; toolchains expecting label resolution where the template only accepts paths.","solutions":["Use an absolute path (/usr/bin/python3) or a bare command name (python3) resolvable via SearchPath for the interpreter.","Resolve the label to a file yourself (e.g. via a genrule/$(location) expansion) and pass the resulting path, never the raw '//' string.","Upgrade to a bazel version / rules_python setup that fully supports label interpreters for your rule set instead of the legacy bootstrap path."],"exampleFix":"# before\npython_interpreter = \"//tools/python:python3_binary\"\n\n# after\npython_interpreter = \"python3\"  # or an absolute path like \"/usr/bin/python3\"","handlingStrategy":"validation","validationCode":"def valid_interpreter_spec(v):\n    return bool(v) and not v.startswith('//')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure interpreters as absolute paths or PATH-resolvable names for legacy bootstrap targets.","Expand labels via $(location) in a genrule instead of passing raw '//' strings."],"tags":["python","bazel","bootstrap","runfiles"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}