A script that calls an external tool and dies with a stack trace because the tool is not installed gives a poor error message. A one-line check fixes that.
shutil.which(cmd) returns the path of the executable that would run, or None if nothing would:
import shutil
if shutil.which("ffmpeg") is None:
raise SystemExit("ffmpeg is not installed")
The same call is useful when you want the full path for a message or a subprocess call:
print(shutil.which("git"))
# /usr/bin/git
It reads PATH from the environment by default. Pass your own search path with path=, for example shutil.which("git", path="/nonexistent"), which returns None. By default it checks that the file exists and is executable, and the mode argument changes that. On Windows it uses PATHEXT to resolve commands without an extension, so "python" can find python.EXE.
Caveats: if the command contains a directory part, the docs say which() checks only that path and does not search PATH, so shutil.which("bin/git") looks for bin/git relative to the current directory. And it tells you the program exists, not that it is the right version. If you need a minimum version, run it with --version afterwards and read the output.
Further reading: shutil.which