{"record":{"id":"d82daf36df2c78e2","repo":"GoogleContainerTools/skaffold","slug":"q-does-not-appear-to-invoke-python","errorCode":null,"errorMessage":"%q does not appear to invoke python","messagePattern":"%q does not appear to invoke python","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/debug/transform_python.go","lineNumber":148,"sourceCode":"\t\t\tRuntime: \"python\",\n\t\t\tPorts:   map[string]uint32{protocol: uint32(spec.port)},\n\t\t}, \"\", nil\n\t}\n\n\tspec := createPythonDebugSpec(overrideProtocols, portAlloc)\n\n\tswitch {\n\tcase isLaunchingPython(config.Entrypoint):\n\t\tcontainer.Command = rewritePythonCommandLine(config.Entrypoint, *spec)\n\n\tcase (len(config.Entrypoint) == 0 || isEntrypointLauncher(config.Entrypoint)) && isLaunchingPython(config.Arguments):\n\t\tcontainer.Args = rewritePythonCommandLine(config.Arguments, *spec)\n\n\tcase hasCommonPythonEnvVars(config.Env):\n\t\tcontainer.Command = rewritePythonCommandLine(config.Entrypoint, *spec)\n\n\tdefault:\n\t\treturn types.ContainerDebugConfiguration{}, \"\", fmt.Errorf(\"%q does not appear to invoke python\", container.Name)\n\t}\n\n\tprotocol := spec.protocol()\n\tcontainer.Ports = exposePort(container.Ports, protocol, spec.port)\n\n\treturn types.ContainerDebugConfiguration{\n\t\tRuntime: \"python\",\n\t\tPorts:   map[string]uint32{protocol: uint32(spec.port)},\n\t}, \"python\", nil\n}\n\nfunc retrievePythonDebugSpec(config ImageConfiguration) *pythonSpec {\n\tif spec := extractPythonDebugSpec(config.Entrypoint); spec != nil {\n\t\treturn spec\n\t}\n\tif spec := extractPythonDebugSpec(config.Arguments); spec != nil {\n\t\treturn spec\n\t}","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/debug/transform_python.go#L130-L166","documentation":"Skaffold's Python debug transformer (`pythonTransformer.Apply`) rewrites a container's entrypoint/args to inject debugpy/ptvsd/pydevd. This error is thrown when the transformer was selected for a container (usually because the user forced the python runtime in skaffold.yaml) but none of the container's entrypoint, args, or env vars indicate that Python is actually invoked. The container name is included in the message to identify which image failed.","triggerScenarios":"Occurs in `Apply` when `MatchRuntime` returned true (user set `runtimeType: python` in the artifact's debug config) but in the switch at pkg/skaffold/debug/transform_python.go:137-148: (1) `isLaunchingPython(config.Entrypoint)` is false, (2) the entrypoint is not a launcher or args don't launch python (`isLaunchingPython(config.Arguments)` false), and (3) `hasCommonPythonEnvVars(config.Env)` is false.","commonSituations":"Debugging a multi-container pod where the user annotated the wrong container as python; a python app started via a wrapper shell script (e.g. entrypoint is `sh -c ...`) that hides the python invocation; an image whose python launch happens via env vars not among the recognized ones (e.g. custom `PYTHON...` vars); python invoked through a compiled launcher binary.","solutions":["Verify the container's ENTRYPOINT/CMD actually invokes python (e.g. `python`, `python3`, `uvicorn`, `gunicorn`, or `-m debugpy`) and that the artifact in skaffold.yaml corresponds to a python image","If the python process is launched indirectly, change the container entrypoint/args to invoke python directly so the transformer can rewrite it","Set a recognized Python env var (e.g. `PYTHONPATH`, `PYTHONUNBUFFERED`, `PYTHON_VERSION`) in the image so `hasCommonPythonEnvVars` matches","Remove `runtimeType: python` from the artifact's debug config if the container is not python (it may have been auto-suggested incorrectly)"],"exampleFix":"// skaffold.yaml (before)\nartifact: my-artifact\ndeg: { artifact: my-image, runtimeType: python }  // image actually launches via sh wrapper\n// after: either drop runtimeType or make the launch explicit\n// Dockerfile before:\nENTRYPOINT [\"sh\", \"-c\", \"./start.sh\"]\n// Dockerfile after:\nENTRYPOINT [\"python3\", \"-m\", \"uvicorn\", \"main:app\", \"--host\", \"0.0.0.0\"]","handlingStrategy":"validation","validationCode":"import (\n\t\"strings\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/debug\"\n)\n\nfunc pythonWillTransform(entrypoint, args []string, env []string) bool {\n\tfor _, e := range env {\n\t\tif k := strings.SplitN(e, \"=\", 2)[0]; strings.HasPrefix(k, \"PYTHON\") {\n\t\t\treturn true\n\t\t}\n\t}\n\tfor _, argv := range [][]string{entrypoint, args} {\n\t\tif len(argv) > 0 {\n\t\t\tbase := strings.ToLower(argv[0])\n\t\t\tif strings.Contains(base, \"python\") {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}","typeGuard":"func isPythonLaunch(argv []string) bool {\n\tif len(argv) == 0 {\n\t\treturn false\n\t}\n\treturn strings.Contains(strings.ToLower(argv[0]), \"python\")\n}","tryCatchPattern":"cfg, workdir, err := transformer.Apply(adapter, imageConfig, portAlloc, protocols)\nif err != nil {\n\tif strings.Contains(err.Error(), \"does not appear to invoke python\") {\n\t\tlog.Warnf(\"skipping debug transform for %s: no python invocation detected\", containerName)\n\t\treturn nil // skip rather than fail the whole debug session\n\t}\n\treturn err\n}","preventionTips":["Only annotate artifacts with `runtimeType: python` when the entrypoint or CMD directly invokes a python binary","Avoid shell-wrapper entrypoints (`sh -c`) for containers you intend to debug in python","Inspect the built image's ENTRYPOINT/CMD (`docker inspect`) before enabling debug mode","Set a common python env var (e.g. PYTHONUNBUFFERED=1) as an explicit runtime hint"],"tags":["debugging","python","skaffold","container-transform"],"backgroundTag":"runtime-mismatch-container-debug","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}