Even when I run simple code like this:
import subprocess
subprocess.run("dir")
I get an error
C:\Users\mrlol\Desktop\Test>py test.py
Traceback (most recent call last):
File "C:\Users\mrlol\Desktop\Test\test.py", line 2, in <module>
subprocess.run("dir")
File "C:\Users\mrlol\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 546, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mrlol\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1022, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\mrlol\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1491, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified
Edit 1 I have added shell=True, but still this issue remains(
C:\Users\mrlol\Desktop\Test>py test.py
Traceback (most recent call last):
File "C:\Users\mrlol\Desktop\Test\test.py", line 2, in <module>
subprocess.run("dir", shell=True)
File "C:\Users\mrlol\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 546, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mrlol\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1022, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\mrlol\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1491, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified
I have used another program and I had an issue. Now I see that it is subprocess causing the issue.