{"id":1837,"library":"gymnasium","title":"Gymnasium Reinforcement Learning Library","description":"Gymnasium provides a standard API for reinforcement learning environments, offering a diverse set of reference environments for research and development. It is the spiritual successor to OpenAI Gym, maintained by the Farama Foundation, and receives frequent minor releases with bug fixes, new features, and API improvements. The current version is 1.2.3.","status":"active","version":"1.2.3","language":"en","source_language":"en","source_url":"https://github.com/Farama-Foundation/Gymnasium","tags":["reinforcement-learning","gym","environment","deep-learning","ai"],"install":[{"cmd":"pip install gymnasium","lang":"bash","label":"Core library"},{"cmd":"pip install gymnasium[classic_control]","lang":"bash","label":"Classic control environments (e.g., CartPole)"},{"cmd":"pip install gymnasium[box2d]","lang":"bash","label":"Box2D environments"},{"cmd":"pip install gymnasium[mujoco]","lang":"bash","label":"Modern MuJoCo environments (v4)"},{"cmd":"pip install 'gymnasium[all]' # installs all official extras","lang":"bash","label":"All environments"}],"dependencies":[{"reason":"Core dependency for array manipulation in observations and spaces.","package":"numpy"},{"reason":"Required for `gymnasium[box2d]` environments (replaces `box2d-py` since v1.2.3).","package":"box2d","optional":true},{"reason":"Required for `gymnasium[mujoco]` environments.","package":"mujoco","optional":true}],"imports":[{"note":"Gymnasium is the successor to OpenAI Gym; the package name changed. Use `import gymnasium as gym`.","wrong":"from gym import make","symbol":"gymnasium.make","correct":"import gymnasium as gym\nenv = gym.make('CartPole-v1')"},{"note":"The core Env class is now directly under the top-level 'gymnasium' package.","wrong":"from gym.core import Env","symbol":"gymnasium.Env","correct":"import gymnasium as gym\nclass MyEnv(gym.Env): ..."},{"note":"Space definitions are accessed via 'gymnasium.spaces'.","wrong":"from gym import spaces","symbol":"gymnasium.spaces","correct":"import gymnasium as gym\nspace = gym.spaces.Box(low=0, high=1, shape=(4,))"}],"quickstart":{"code":"import gymnasium as gym\n\nenv = gym.make(\"CartPole-v1\", render_mode=\"rgb_array\")\nobservation, info = env.reset(seed=42) # seed is optional, for reproducibility\n\nfor _ in range(100):\n    action = env.action_space.sample()  # agent policy that takes an observation and returns an action\n    observation, reward, terminated, truncated, info = env.step(action)\n\n    if terminated or truncated:\n        observation, info = env.reset(seed=42)\nenv.close()","lang":"python","description":"Initializes a CartPole-v1 environment, steps through it for 100 timesteps using random actions, and resets when the episode terminates or truncates. Demonstrates the modern `render_mode` parameter, the `seed` argument for `reset()`, and the split `terminated`/`truncated` flags from `step()`."},"warnings":[{"fix":"Replace `import gym` with `import gymnasium as gym` (or similar) in all your code.","message":"The library package name changed from `gym` to `gymnasium` starting with v0.29.0 and definitively from v1.0.0. All imports must be updated.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Update calls from `obs = env.reset()` to `obs, info = env.reset()` and adjust your code to handle the `info` dictionary.","message":"The `Env.reset()` method now returns a tuple `(observation, info)` instead of just `observation`. The `info` dictionary provides additional diagnostic information.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Update calls from `obs, reward, done, info = env.step(action)` to `obs, reward, terminated, truncated, info = env.step(action)`. Adjust logic from `if done:` to `if terminated or truncated:`.","message":"The `Env.step()` method now returns `(observation, reward, terminated, truncated, info)`. The single boolean `done` has been split into `terminated` (true if the environment reached a terminal state) and `truncated` (true if the episode ended due to a time limit or other external factor).","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"When calling `gymnasium.make()`, include `render_mode=\"rgb_array\"`, `render_mode=\"human\"`, or `render_mode=None` as appropriate for your use case.","message":"The `render_mode` argument in `gymnasium.make()` is now mandatory if you intend to render the environment. If rendering is not needed, set it to `None`.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Install `gymnasium-robotics` (`pip install gymnasium-robotics`) and update environment IDs if you rely on these specific MuJoCo versions. For modern MuJoCo environments (v4), use `gymnasium[mujoco]`.","message":"MuJoCo v2 and v3 environments (e.g., 'Ant-v2', 'Humanoid-v3') have been moved to the `gymnasium-robotics` project. They are no longer part of the core `gymnasium` library.","severity":"breaking","affected_versions":">=1.2.0"},{"fix":"Ensure `pip install gymnasium[box2d]` or manually install `box2d` if managing dependencies yourself. Do not rely on `box2d-py` for `gymnasium` versions 1.2.3 and later.","message":"The `gymnasium[box2d]` extra now depends on the `box2d` package, replacing the older `box2d-py`. Installing the extra will handle this automatically, but manual installations might cause issues.","severity":"gotcha","affected_versions":">=1.2.3"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}