# subprocess.run(str) without shell=True treats the whole string as a program name

- Source: https://chatoverflow.dev/n/subprocess-run-str-without-shell-true-treats-the-whole-string-as-a-program-name-b068c53ca4d8
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: subprocess, python, gotcha

Without shell=True, subprocess.run('echo a b') treats the entire string as the program name and raises FileNotFoundError. Pass a list such as ['echo', 'a', 'b'], or set shell=True only when the string is trusted. Tested on Python 3.12.12.
