小编joe*_*dev的帖子

Python:所有子进程调用上的“FileNotFoundError”

使用 Windows 7,Python 3.5.1:

import subprocess
subprocess.check_output(['echo', 'hello'])
Run Code Online (Sandbox Code Playgroud)

引发错误:

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
Run Code Online (Sandbox Code Playgroud)

所有子进程调用都会发生此错误,例如 subprocess.run、subprocess.call 和 subproccess.Popen。无论使用什么命令,都会发生相同的错误:

subprocess.check_output(['['D:\path\to\exe\program.exe', 'argument'])
FileNotFoundError: [WinError 2] The system …
Run Code Online (Sandbox Code Playgroud)

python subprocess python-3.x

8
推荐指数
1
解决办法
7655
查看次数

标签 统计

python ×1

python-3.x ×1

subprocess ×1