subprocess出现FileNotFoundError错误

subprocess出现FileNotFoundError错误

1.问题描述

在使用autogluon库时,出现如下错误(大致上一样,原本的错误已丢失):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Traceback (most recent call last):
File "C:/Users/denys/Documents/GitHub/unity_AI/brawlhalla/policy_server.py", line 166, in <module>
ray.init(log_to_driver=False)
File "C:\Python\lib\site-packages\ray\_private\client_mode_hook.py", line 105, in wrapper
return func(*args, **kwargs)
File "C:\Python\lib\site-packages\ray\worker.py", line 1022, in init
_global_node = ray.node.Node(
File "C:\Python\lib\site-packages\ray\node.py", line 301, in __init__
self.start_ray_processes()
File "C:\Python\lib\site-packages\ray\node.py", line 1130, in start_ray_processes
resource_spec = self.get_resource_spec()
File "C:\Python\lib\site-packages\ray\node.py", line 472, in get_resource_spec
self._resource_spec = ResourceSpec(
File "C:\Python\lib\site-packages\ray\_private\resource_spec.py", line 178, in resolve
num_gpus = _autodetect_num_gpus()
File "C:\Python\lib\site-packages\ray\_private\resource_spec.py", line 295, in _autodetect_num_gpus
lines = subprocess.check_output(cmdargs).splitlines()[1:]
File "C:\Python\lib\subprocess.py", line 415, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "C:\Python\lib\subprocess.py", line 493, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Python\lib\subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Python\lib\subprocess.py", line 1311, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

2.解决办法

可能是环境变量的问题,在Path中加入:

1
2
3
%SystemRoot%\System32
%SystemRoot%\System32\Wbem
%SystemRoot%\System32\wbem

之后就可能解决。要注意的是,这里已经有C:\Windows\System32,但似乎还不够……


subprocess出现FileNotFoundError错误
https://fulequn.github.io/2022/11/Article202211011/
作者
Fulequn
发布于
2022年11月1日
许可协议