Wrapper class that converts gym.Env into GymEnv.

KNOWN_GYM_NOT_CLOSE_VIEWER = ['gym.envs.atari', 'gym.envs.box2d', 'gym.envs.classic_control']
KNOWN_GYM_NOT_CLOSE_MJ_VIEWER = ['gym.envs.mujoco', 'gym.envs.robotics']
class GymEnv(env, is_image=False, max_episode_length=None)

Bases: garage.Environment

Inheritance diagram of garage.envs.gym_env.GymEnv

Returns an abstract Garage wrapper class for gym.Env.

In order to provide pickling (serialization) and parameterization for gym.Env instances, they must be wrapped with GymEnv. This ensures compatibility with existing samplers and checkpointing when the envs are passed internally around garage.

Furthermore, classes inheriting from GymEnv should silently convert :attribute:`action_space` and :attribute:`observation_space` from gym.Space to akro.Space.

GymEnv handles all environments created by make().

It returns a different wrapper class instance if the input environment requires special handling. Current supported wrapper classes are:

garage.envs.bullet.BulletEnv for Bullet-based gym environments.

See __new__() for details.

property action_space(self)

akro.Space: The action space specification.

property observation_space(self)

akro.Space: The observation space specification.

property spec(self)

garage.envs.env_spec.EnvSpec: The envionrment specification.

property render_modes(self)

list: A list of string representing the supported render modes.


Call reset on wrapped env.


The first observation conforming to


dict: The episode-level information.

Note that this is not part of env_info provided in step(). It contains information of he entire episode, which could be needed to determine the first action (e.g. in the case of goal-conditioned or MTRL.)

Return type


step(self, action)

Call step on wrapped env.


action (np.ndarray) – An action provided by the agent.


The environment step resulting from the action.

Return type


  • RuntimeError – if step() is called after the environment has been constructed and reset() has not been called.

  • RuntimeError – if underlying environment outputs inconsistent env_info keys.

render(self, mode)

Renders the environment.


mode (str) – the mode to render with. The string must be present in self.render_modes.


the return value for render, depending on each env.

Return type



Creates a visualization of the environment.


Close the wrapped env.