PaddlePaddle/MetaGym

报错 python -m metagym.quadrotor.env hovering_control

qa6300525 opened this issue · 4 comments

python -m metagym.quadrotor.env hovering_control

/Users/chengmaoyu/anaconda3/envs/rl-3.9/lib/python3.9/runpy.py:127: RuntimeWarning: 'metagym.quadrotor.env' found in sys.modules after import of package 'metagym.quadrotor', but prior to execution of 'metagym.quadrotor.env'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))
Traceback (most recent call last):
File "/Users/chengmaoyu/anaconda3/envs/rl-3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Users/chengmaoyu/anaconda3/envs/rl-3.9/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/chengmaoyu/code/test/rl/MetaGym/metagym/quadrotor/env.py", line 317, in
env.render()
File "/Users/chengmaoyu/code/test/rl/MetaGym/metagym/quadrotor/env.py", line 172, in render
raise RuntimeError('[Error] Cannot connect to display screen.')
RuntimeError: [Error] Cannot connect to display screen.

版本信息
gym 0.23.1
gym-notices 0.0.6
metagym 0.1.0
numpy 1.22.3

我已经解决了,原因是
MetaGym/metagym/quadrotor/env.py:25 文件中
try:
from metagym.quadrotor.render import RenderWindow
except Exception as e:
print(e) # 本来没有这句
NO_DISPLAY = True

导致如果引用出错不会打印原因,我手动将原因打印出来,发现是包缺失,安装之后就能够跑了。

#请问是缺少那些包呢?我遇到跟您一模一样的问题。

可否贴出具体问题描述?从上面报错看,需要确认机器上面是否有显示设备或者GUI。如果没有,建议把enable_render关掉

可否贴出具体问题描述?从上面报错看,需要确认机器上面是否有显示设备或者GUI。如果没有,建议把enable_render关掉

您好。使用的是windows。我想在命令行看一下的"Quadrotor", task="hovering_control"的渲染效果。问题在最后,请问如何解决
命令行输入如下:

from rlschool import make_env
env = make_env("Quadrotor", task="hovering_control")
env.reset()
array([ 0.3764959 , 1.1376995 , 0.6062036 , 0. , 0. ,
0. , 0. , 0. , -9.8 , -3.2034495 ,
-2.0571785 , 0.82844687, -0. , 0. , 0. ,
5. ], dtype=float32)
env.render()
Traceback (most recent call last):
File "", line 1, in
File "D:\ProgramData\Anaconda3\envs\RFlearning\lib\site-packages\rlschool\quadrotor\env.py", line 166, in render
raise RuntimeError('[Error] Cannot connect to display screen.')
RuntimeError: [Error] Cannot connect to display screen.