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 --versionCall 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.txtHow to prevent it
- Always pin the interpreter with setup-python in CI.
- Reference
python3or use the version setup-python puts on PATH. - Verify
python --versionearly in the job.
Related guides
pyenv "version not installed" on the runner in CIFix pyenv "version `X' is not installed" in CI - the .python-version pins an interpreter pyenv has not built…
Python version mismatch (.python-version vs CI) in CIFix a Python version mismatch in CI - the runner uses a different interpreter than your `.python-version` / `…
pip "command not found" on the runner in CIFix "pip: command not found" in CI - the runner has Python but no `pip` on PATH, or pip lives only as a modul…