Importerror:无法导入渲染' from' gym.envs.classic_control'
我正在与RL代理合作,并试图复制此 Paper ,在其中,他们根据健身房开设了自定义的跑酷环境,但是当试图渲染我遇到的环境时。
import numpy as np
import time
import gym
import TeachMyAgent.environments
env = gym.make('parametric-continuous-parkour-v0', agent_body_type='fish', movable_creepers=True)
env.set_environment(input_vector=np.zeros(3), water_level = 0.1)
env.reset()
while True:
_, _, d, _ = env.step(env.action_space.sample())
env.render(mode='human')
time.sleep(0.1)
c:\users\manu dwivedi\teachmyagent\TeachMyAgent\environments\envs\parametric_continuous_parkour.py in render(self, mode, draw_lidars)
462
463 def render(self, mode='human', draw_lidars=True):
--> 464 from gym.envs.classic_control import rendering
465 if self.viewer is None:
466 self.viewer = rendering.Viewer(RENDERING_VIEWER_W, RENDERING_VIEWER_H)
ImportError: cannot import name 'rendering' from 'gym.envs.classic_control' (C:\ProgramData\Anaconda3\envs\teachagent\lib\site-packages\gym\envs\classic_control\__init__.py)
[1]: https://github.com/flowersteam/TeachMyAgent
我认为这可能是此自定义环境的问题,以及作者如何决定将其渲染,但是,当我尝试
from gym.envs.classic_control import rendering
遇到相同的错误时,Github用户在这里建议通过添加rendor_mode ='human'
在调用code> gym.make()
时,可以解决这一点。渲染,但这似乎只是为了特定情况。
I'm working with RL agents, and was trying to replicate the finding of the this paper, wherein they make a custom parkour environment based on Gym open AI, however when trying to render this environment I run into.
import numpy as np
import time
import gym
import TeachMyAgent.environments
env = gym.make('parametric-continuous-parkour-v0', agent_body_type='fish', movable_creepers=True)
env.set_environment(input_vector=np.zeros(3), water_level = 0.1)
env.reset()
while True:
_, _, d, _ = env.step(env.action_space.sample())
env.render(mode='human')
time.sleep(0.1)
c:\users\manu dwivedi\teachmyagent\TeachMyAgent\environments\envs\parametric_continuous_parkour.py in render(self, mode, draw_lidars)
462
463 def render(self, mode='human', draw_lidars=True):
--> 464 from gym.envs.classic_control import rendering
465 if self.viewer is None:
466 self.viewer = rendering.Viewer(RENDERING_VIEWER_W, RENDERING_VIEWER_H)
ImportError: cannot import name 'rendering' from 'gym.envs.classic_control' (C:\ProgramData\Anaconda3\envs\teachagent\lib\site-packages\gym\envs\classic_control\__init__.py)
[1]: https://github.com/flowersteam/TeachMyAgent
I thought this might be a problem with this custom environments and how the authors decided to render it, however, when I try just
from gym.envs.classic_control import rendering
I run into the same error, github users here suggested this can be solved by adding rendor_mode='human'
when calling gym.make()
rendering, but this seems to only goes for their specific case.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我(在同学的帮助下)通过将
Gym
软件包降低到0.21.0来工作。为此执行了命令
pip install gym == 0.21.0
。更新,摘自GitHub问题:
基于 https://github.com/ OpenAi/Gym/essess/2779
这应该是GymGrid的问题,有一个开放式PR: WSGDRFZ/GYMGRID#1
如果您想使用最后版本的健身房,可以尝试使用该pr的分支( https:// github。 com/cedrichermansbit/gymgrid2 );您可以使用
PIP安装安装GymGrid2
安装它I got (with help from a fellow student) it to work by downgrading the
gym
package to 0.21.0.Performed the command
pip install gym==0.21.0
for this.Update, from Github issue:
Based on https://github.com/openai/gym/issues/2779
This should be a problem of gymgrid, there is an open PR: wsgdrfz/gymgrid#1
If you want to use the last version of gym, you can try using the branch of that PR (https://github.com/CedricHermansBIT/gymgrid2); you can install it with
pip install gymgrid2