{"record":{"id":"9943432f6697a0fb","repo":"can1357/oh-my-pi","slug":"python-executable-not-found-on-path","errorCode":null,"errorMessage":"Python executable not found on PATH","messagePattern":"Python executable not found on PATH","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/coding-agent/src/eval/py/runtime.ts","lineNumber":273,"sourceCode":"\t}\n\n\tconst systemPath = $which(\"python\") ?? $which(\"python3\");\n\tif (systemPath) {\n\t\tpush({ pythonPath: systemPath, env: { ...baseEnv } });\n\t}\n\n\treturn runtimes;\n}\n\n/**\n * Resolve the highest-priority Python runtime. Prefer {@link enumeratePythonRuntimes}\n * when you can probe candidates; this returns only the first one and throws when\n * no interpreter exists.\n */\nexport function resolvePythonRuntime(cwd: string, baseEnv: Record<string, string | undefined>): PythonRuntime {\n\tconst [runtime] = enumeratePythonRuntimes(cwd, baseEnv);\n\tif (!runtime) {\n\t\tthrow new Error(\"Python executable not found on PATH\");\n\t}\n\treturn runtime;\n}\n","sourceCodeStart":255,"sourceCodeEnd":277,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/eval/py/runtime.ts#L255-L277","documentation":"resolvePythonRuntime picks the first Python interpreter found by enumeratePythonRuntimes for the given cwd/base environment. If no interpreter exists it throws Error 'Python executable not found on PATH' instead of returning a runtime. enumeratePythonRuntimes is the probing variant; this function is for callers that require an interpreter.","triggerScenarios":"Starting the Python eval runtime on a machine with no python/python3 (or venv) discoverable via the candidate enumeration in cwd or baseEnv PATH — e.g. resolvePythonRuntime(cwd, env) in a slim Docker image or minimal CI runner.","commonSituations":"Alpine/slim containers without python installed, Windows machines with Python installed but python.exe not on PATH, broken virtualenv references (venv python deleted), or a sanitized env stripping PATH.","solutions":["Install Python and ensure it is on PATH (python3 on Linux/macOS, python.exe on Windows)","Create or repair the virtualenv expected in the project directory","Pass a baseEnv whose PATH includes the interpreter's directory, or point the runtime at a known interpreter path","Use enumeratePythonRuntimes to probe candidates and fall back to an explicit interpreter path"],"exampleFix":"// before\nconst runtime = resolvePythonRuntime(cwd, {});\n// after\nconst candidates = enumeratePythonRuntimes(cwd, baseEnv);\nif (candidates.length === 0) throw new Error(\"Install python3 or set PY_BIN\");\nconst runtime = candidates[0];","handlingStrategy":"fallback","validationCode":"import { enumeratePythonRuntimes } from \"...\";\nconst candidates = enumeratePythonRuntimes(cwd, baseEnv);\nif (candidates.length === 0) {\n  // surface install guidance before calling resolvePythonRuntime\n}","typeGuard":null,"tryCatchPattern":"let runtime;\ntry {\n  runtime = resolvePythonRuntime(cwd, baseEnv);\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"Python executable not found\")) {\n    throw new Error(\"Install Python 3 and ensure it is on PATH\");\n  }\n  throw e;\n}","preventionTips":["Ensure python3/python is installed and on PATH in containers and CI","Pass a baseEnv with a sane PATH, don't sanitize it away","Repair or recreate broken virtualenvs before starting the runtime","Prefer enumeratePythonRuntimes when you want to probe and fall back"],"tags":["python","environment","path","runtime"],"backgroundTag":"missing-python-interpreter","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}