Подпроцесс возвращает ошибку «файл не найден» всякий раз, когда я пытаюсь запустить что-либо с его помощью [дубликат] ⇐ Python
-
Anonymous
Подпроцесс возвращает ошибку «файл не найден» всякий раз, когда я пытаюсь запустить что-либо с его помощью [дубликат]
the code is simply just
import os import subprocess os.system("dir") subprocess.run("dir") , but when subprocess gets called, it returns
FileNotFoundError: [WinError 2] The system cannot find the file specified . So how do I fix this? (full error log)
PS C:\Users\...\> & C:/Python311/python.exe c:/Users/.../errorfixing.py Volume in drive C is OS Volume Serial Number is CCCE-1A39 Directory of C:\Users\...\ 03/03/2024 12:45 . 03/03/2024 12:45 .. 03/03/2024 15:50 69 errorfixing.py 03/03/2024 15:47 4,486 main.py 03/03/2024 12:20 media 03/03/2024 15:33 22 other.py 03/03/2024 11:46 35 other.txt 03/03/2024 14:54 62 other2.py 03/03/2024 15:32 11 stdout.txt 6 File(s) 4,685 bytes 3 Dir(s) 49,271,283,712 bytes free Traceback (most recent call last): File "c:\Users\...\errorfixing.py", line 4, in subprocess.run("dir") File "C:\Python311\Lib\subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\subprocess.py", line 1024, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Python311\Lib\subprocess.py", line 1509, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [WinError 2] The system cannot find the file specified
Источник: https://stackoverflow.com/questions/780 ... hing-using
the code is simply just
import os import subprocess os.system("dir") subprocess.run("dir") , but when subprocess gets called, it returns
FileNotFoundError: [WinError 2] The system cannot find the file specified . So how do I fix this? (full error log)
PS C:\Users\...\> & C:/Python311/python.exe c:/Users/.../errorfixing.py Volume in drive C is OS Volume Serial Number is CCCE-1A39 Directory of C:\Users\...\ 03/03/2024 12:45 . 03/03/2024 12:45 .. 03/03/2024 15:50 69 errorfixing.py 03/03/2024 15:47 4,486 main.py 03/03/2024 12:20 media 03/03/2024 15:33 22 other.py 03/03/2024 11:46 35 other.txt 03/03/2024 14:54 62 other2.py 03/03/2024 15:32 11 stdout.txt 6 File(s) 4,685 bytes 3 Dir(s) 49,271,283,712 bytes free Traceback (most recent call last): File "c:\Users\...\errorfixing.py", line 4, in subprocess.run("dir") File "C:\Python311\Lib\subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\subprocess.py", line 1024, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Python311\Lib\subprocess.py", line 1509, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [WinError 2] The system cannot find the file specified
Источник: https://stackoverflow.com/questions/780 ... hing-using