Skip to content

KeyError: 'render.modes' in GymEnv wrapping "CartPole-vX" #2321

Description

@AndreaFinazzi

Apparently, classic control environments in Gym have a different key for render modes in env.metadata.

In fact:

>>> import gym
>>> env = gym.make('CartPole-v1')
>>> env.metadata
{'render_modes': ['human', 'rgb_array'], 'render_fps': 50}

While in the garage wrapper it expects to find env.metadata['render.modes'], as it is for other environments.

self._render_modes = self._env.metadata['render.modes']

This results in a KeyError, unsurprisingly:

$ python examples/tf/trpo_cartpole.py 
Traceback (most recent call last):
  File "examples/tf/trpo_cartpole.py", line 57, in <module>
    trpo_cartpole()
  File "/home/***/.local/lib/python3.8/site-packages/garage/experiment/experiment.py", line 369, in __call__
    result = self.function(ctxt, **kwargs)
  File "examples/tf/trpo_cartpole.py", line 33, in trpo_cartpole
    env = GymEnv('CartPole-v1')
  File "/home/***/.local/lib/python3.8/site-packages/garage/envs/gym_env.py", line 147, in __init__
    self._render_modes = self._env.metadata['render.modes']
KeyError: 'render.modes'

Is it a problem of my version mix? I run with:

  • garage==2021.3.0
  • gym==0.23.1

Thank you all for the great work!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions