Why This Happens
subprocess.run() looks for the executable on the system PATH. If not installed or misspelled, it raises FileNotFoundError.
The Problem
import subprocess
result = subprocess.run(['my-script', '--flag'])The Fix
import subprocess, shutil
if shutil.which('my-script'):
result = subprocess.run(['my-script', '--flag'])
else:
print('my-script is not installed')Step-by-Step Fix
- 1
Verify command exists
Use shutil.which('command') to check.
- 2
Use full path
Specify the complete path to the executable.
- 3
Check shell features
Use shell=True for pipes/redirects, but avoid with untrusted input.
Bugsly catches this automatically
Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.
Try Bugsly free