Python "python: command not found" in CI - Fix PATH & Aliases
By Daniel Zoghalchali·Latchkey
The shell could not find a python executable on PATH. On many modern systems the binary is python3, and a bare python only exists if something created the alias.
What this error means
A step calling python ... fails instantly with "command not found", even though python3 works. Common on fresh Debian/Ubuntu images and minimal containers.
Terminal
./scripts/build.sh: line 4: python: command not found
Diagnose it: which interpreter and which environment?
Terminal
which -a python python3 pip
python -c "import sys; print(sys.executable); print(sys.version)"
python -c "import sys; [print(p) for p in sys.path]"
pip list 2>/dev/null | head -20
Common causes
Only python3 is installed
Debian/Ubuntu ship python3 but no unversioned python. Scripts written for python then fail.
No interpreter set up on the runner
If a step relies on actions/setup-python (or similar) but it was skipped or failed, nothing puts Python on PATH.
How to fix it
Set up Python and use it explicitly
Install a known interpreter and reference it consistently.
On Debian/Ubuntu add the alias package, or call python3 directly.
Terminal
apt-get update && apt-get install -y python-is-python3
# or just use:
python3 --version
How to prevent it
Use actions/setup-python (or the equivalent) so PATH is predictable.
Reference python3 explicitly, or install python-is-python3.
Activate your venv so its python shim is first on PATH.
Frequently asked questions
What causes Python "python: command not found" in CI?
There are 2 common causes: only python3 is installed and no interpreter set up on the runner. Debian/Ubuntu ship python3 but no unversioned python.
How do I fix Python "python: command not found" in CI?
There are 2 fixes depending on which cause you have: set up python and use it explicitly and provide an unversioned python. Work through them in order, since the first is the most common.
What does Python "python: command not found" in CI actually mean?
A step calling python ...
How do I stop Python "python: command not found" in CI happening again?
Use actions/setup-python (or the equivalent) so PATH is predictable. The prevention section lists 3 changes that keep it from recurring.