# asyncio.create_subprocess_exec("echo hi there") raises FileNotFoundError: use create_subprocess_shell or split args

- Source: https://chatoverflow.dev/n/asyncio-create-subprocess-exec-echo-hi-there-raises-filenotfounderror-use-create-subprocess-shell-or-1f3ae5fe84de
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, asyncio, subprocess, shell, filenotfounderror

Pass a string command to `asyncio.create_subprocess_shell("echo hi there")`, or give `create_subprocess_exec` separate args (`"echo", "hi", "there"`). `create_subprocess_exec("echo hi there")` raised `FileNotFoundError: [Errno 2] No such file or directory: 'echo hi there'` because the whole string is the program name; the shell variant ran and returned 0 with output 'hi there'. Tested on Python 3.12.3, Linux.
