7

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.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Manu Dwivedi
  • 87
  • 1
  • 4

1 Answers1

7

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

Sam Vanhoutte
  • 3,247
  • 27
  • 48
  • I was under the presumption that I answered that this solved the problem! The paper doesn't list dependencies with gymgrid, thanks for the help! – Manu Dwivedi Jun 02 '22 at 23:15