Using Windows 7, Python 3.5.1:
import subprocess
subprocess.check_output(['echo', 'hello'])
raises the error:
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
subprocess.check_output(['echo', 'hello'])
File "D:\Programs\Python 3.5.1\lib\subprocess.py", line 629, in check_output
**kwargs).stdout
File "D:\Programs\Python 3.5.1\lib\subprocess.py", line 696, in run
with Popen(*popenargs, **kwargs) as process:
File "D:\Programs\Python 3.5.1\lib\subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "D:\Programs\Python 3.5.1\lib\subprocess.py", line 1220, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
This error occurs with all subprocess calls, such as subprocess.run, subprocess.call, and subproccess.Popen. The same error happens regardless of what command is used:
subprocess.check_output(['['D:\path\to\exe\program.exe', 'argument'])
FileNotFoundError: [WinError 2] The system cannot find the file specified
As far as I can tell, this error usually occurs when the command tries to execute a nonexistent path, but I can't determine why it would occur in these cases.