SECURITY WARNING: Never run commands you don't understand. Always review code before execution. Use at your own risk.
Shell New Added 17 October 2026

/usr/bin/env: 'python': No such file or directory

The script's shebang asks for a command called python, and current Debian, Ubuntu, Fedora and macOS releases only ship python3. Python 3 is installed; there is just no executable with the bare name. It also catches scripts saved with Windows line endings, where env looks for 'python\r' and the message prints oddly because of the hidden carriage return.

Quick fix

Read the commands before running them. Anything that restarts a service, deletes data or changes permissions should be tried on a non-production system first.

Quick fix
# Is there a python3 but no python?
command -v python3 python

# Check for CRLF line endings too (shows ^M at the end of the first line)
head -1 script.py | cat -A
sed -i "s/\r$//" script.py

# Best fix: make the shebang ask for what exists
sed -i '1s|^#!.*python$|#!/usr/bin/env python3|' script.py

# Or, on Debian and Ubuntu, provide the alias system-wide
sudo apt install python-is-python3

# Inside a virtualenv, python exists once it is activated
source .venv/bin/activate && python --version

How to diagnose Shell errors

Shell errors are usually about PATH, permissions, or quoting and expansion. The quoting class is the most damaging because it fails silently: an unquoted variable containing a space becomes two arguments, and an empty one disappears entirely. Running shellcheck over any script longer than a few lines catches most of these before they run.

If the quick fix above does not resolve it, work through these steps. They apply to this whole class of error, not just to this one message, which is usually what saves the time.

  1. Trace execution with bash -x script.sh to see each command after expansion. This makes quoting bugs immediately visible.
  2. Start every script with set -euo pipefail so failures stop the script instead of cascading.
  3. Quote every variable expansion: "$var", "${arr[@]}". This single habit prevents the majority of shell bugs.
  4. Use command -v foo to check whether something is on PATH, and echo "$PATH" to see what the shell is actually searching.
  5. In Makefiles, recipe lines must begin with a real tab character. "missing separator" always means spaces were used instead.

Tools worth reaching for

  • shellcheck
  • bash -x
  • set -euo pipefail
  • command -v
  • cat -A (to reveal tabs)

Authoritative references

Primary documentation for this error, worth reading before applying any fix in production.

peps.python.org man7.org

Related Shell errors

See all 19 Shell errors →

Browse other categories

Something missing or wrong?

This entry is maintained by hand. If the fix is out of date, incomplete, or you have a better one, email a correction and it will be reviewed.