Importerror:无法导入渲染' from' gym.envs.classic_control'

发布于 2025-01-23 19:06:35 字数 1533 浏览 5 评论 0原文

我正在与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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一刻暧昧 2025-01-30 19:06:35

我(在同学的帮助下)通过将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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文