Skip to content
Latchkey

Python "command not found" / wrong version on the runner in CI

The shell could not find a python executable, or it resolved a different version than you expected. Some images ship only python3; others need setup-python to put the chosen interpreter on PATH.

What this error means

A step fails with "python: command not found" (exit 127), or python --version reports a version you did not select.

python
/home/runner/work/_temp/script.sh: line 1: python: command not found
Error: Process completed with exit code 127.

Common causes

Only python3 is on PATH

The base image provides python3 but no python alias, so a bare python call fails.

No interpreter selected for the job

Without setup-python, the step uses whatever default the image has - possibly the wrong version or none.

How to fix it

Provision the interpreter with setup-python

setup-python puts the selected version on PATH as both python and python3.

.github/workflows/ci.yml
- uses: actions/setup-python@v5
  with:
    python-version: '3.12'
- run: python --version

Call python3 explicitly if needed

On images without a python alias, use python3 directly in the step.

Terminal
python3 --version
python3 -m pip install -r requirements.txt

How to prevent it

  • Always pin the interpreter with setup-python in CI.
  • Reference python3 or use the version setup-python puts on PATH.
  • Verify python --version early in the job.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →