GoogleContainerTools/skaffold · error
%q does not appear to invoke python
Error message
%q does not appear to invoke python
What it means
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.
Source
Thrown at pkg/skaffold/debug/transform_python.go:148
Runtime: "python",
Ports: map[string]uint32{protocol: uint32(spec.port)},
}, "", nil
}
spec := createPythonDebugSpec(overrideProtocols, portAlloc)
switch {
case isLaunchingPython(config.Entrypoint):
container.Command = rewritePythonCommandLine(config.Entrypoint, *spec)
case (len(config.Entrypoint) == 0 || isEntrypointLauncher(config.Entrypoint)) && isLaunchingPython(config.Arguments):
container.Args = rewritePythonCommandLine(config.Arguments, *spec)
case hasCommonPythonEnvVars(config.Env):
container.Command = rewritePythonCommandLine(config.Entrypoint, *spec)
default:
return types.ContainerDebugConfiguration{}, "", fmt.Errorf("%q does not appear to invoke python", container.Name)
}
protocol := spec.protocol()
container.Ports = exposePort(container.Ports, protocol, spec.port)
return types.ContainerDebugConfiguration{
Runtime: "python",
Ports: map[string]uint32{protocol: uint32(spec.port)},
}, "python", nil
}
func retrievePythonDebugSpec(config ImageConfiguration) *pythonSpec {
if spec := extractPythonDebugSpec(config.Entrypoint); spec != nil {
return spec
}
if spec := extractPythonDebugSpec(config.Arguments); spec != nil {
return spec
}View on GitHub (pinned to a1189de023)
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)
Example fix
// skaffold.yaml (before)
artifact: my-artifact
deg: { artifact: my-image, runtimeType: python } // image actually launches via sh wrapper
// after: either drop runtimeType or make the launch explicit
// Dockerfile before:
ENTRYPOINT ["sh", "-c", "./start.sh"]
// Dockerfile after:
ENTRYPOINT ["python3", "-m", "uvicorn", "main:app", "--host", "0.0.0.0"] Defensive patterns
Strategy: validation
Validate before calling
import (
"strings"
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/debug"
)
func pythonWillTransform(entrypoint, args []string, env []string) bool {
for _, e := range env {
if k := strings.SplitN(e, "=", 2)[0]; strings.HasPrefix(k, "PYTHON") {
return true
}
}
for _, argv := range [][]string{entrypoint, args} {
if len(argv) > 0 {
base := strings.ToLower(argv[0])
if strings.Contains(base, "python") {
return true
}
}
}
return false
} Type guard
func isPythonLaunch(argv []string) bool {
if len(argv) == 0 {
return false
}
return strings.Contains(strings.ToLower(argv[0]), "python")
} Try / catch
cfg, workdir, err := transformer.Apply(adapter, imageConfig, portAlloc, protocols)
if err != nil {
if strings.Contains(err.Error(), "does not appear to invoke python") {
log.Warnf("skipping debug transform for %s: no python invocation detected", containerName)
return nil // skip rather than fail the whole debug session
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- setting up debugger
- `apply` requires at least one manifest argument
- `exec` requires exactly one action to execute
- `config-dependencies add` requires exactly one file path arg
- `jobManifestPaths modify` requires exactly one manifest file
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/d82daf36df2c78e2.
Report an issue: GitHub.