Registry / ai-ml / gymnasium

gymnasium

JSON →
library1.3.0pypypi✓ verified 25d ago

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.

pip install gymnasium
INSTALL
IMPORT
SIG · GYMNASIUM
G
gymnasium
ai-mlpythonv1.3.0
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
2/5 runs
4/5 runs
py 3.11
1/5 runs
4/5 runs
py 3.12
1/5 runs
4/5 runs
py 3.13
1/5 runs
4/5 runs
py 3.9
2/5 runs
2/5 runs
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

gymnasium.make
import gymnasium as gym env = gym.make('CartPole-v1')
from gym import make
Gymnasium is the successor to OpenAI Gym; the package name changed. Use `import gymnasium as gym`.
gymnasium.Env
import gymnasium as gym class MyEnv(gym.Env): ...
from gym.core import Env
The core Env class is now directly under the top-level 'gymnasium' package.
gymnasium.spaces
import gymnasium as gym space = gym.spaces.Box(low=0, high=1, shape=(4,))
from gym import spaces
Space definitions are accessed via 'gymnasium.spaces'.

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()`.

import gymnasium as gym env = gym.make("CartPole-v1", render_mode="rgb_array") observation, info = env.reset(seed=42) # seed is optional, for reproducibility for _ in range(100): action = env.action_space.sample() # agent policy that takes an observation and returns an action observation, reward, terminated, truncated, info = env.step(action) if terminated or truncated: observation, info = env.reset(seed=42) env.close()
Debug
Known issues
breakingThe library package name changed from `gym` to `gymnasium` starting with v0.29.0 and definitively from v1.0.0. All imports must be updated.
fix
Replace `import gym` with `import gymnasium as gym` (or similar) in all your code.
affects: >=1.0.0
breakingThe `Env.reset()` method now returns a tuple `(observation, info)` instead of just `observation`. The `info` dictionary provides additional diagnostic information.
fix
Update calls from `obs = env.reset()` to `obs, info = env.reset()` and adjust your code to handle the `info` dictionary.
affects: >=1.0.0
breakingThe `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).
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:`.
affects: >=1.0.0
breakingThe `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`.
fix
When calling `gymnasium.make()`, include `render_mode="rgb_array"`, `render_mode="human"`, or `render_mode=None` as appropriate for your use case.
affects: >=1.0.0
breakingMuJoCo 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.
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]`.
affects: >=1.2.0
gotchaThe `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.
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.
affects: >=1.2.3
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'gymnasium'
The 'gymnasium' library is not installed in your current Python environment.
fix
Run `pip install gymnasium` in your terminal to install the library.
ModuleNotFoundError: No module named 'gym'
You are attempting to import the legacy 'gym' library, but it is either not installed, or you intend to use the 'gymnasium' library which is its spiritual successor.
fix
If you intend to use Gymnasium, change `import gym` to `import gymnasium as gym` and ensure 'gymnasium' is installed with `pip install gymnasium`.
gymnasium.error.NamespaceNotFound: Namespace ALE not found. Have you installed the proper package for ALE?
This error occurs when trying to create an Atari environment (e.g., 'ALE/Breakout-v5') using `gymnasium.make()` without having installed the necessary extra dependencies for Atari environments.
fix
Install the Atari dependencies for Gymnasium using `pip install "gymnasium[atari, accept-rom-license]"`.
AttributeError: 'module' object has no attribute 'make'
This error often indicates that you are attempting to use `gym.make()` from the legacy 'gym' library, but either 'gym' is not installed, an incompatible version is present, or you have 'gymnasium' installed and imported as 'gym', but the specific environment or functionality is not compatible with the Gymnasium API.
fix
Ensure you are consistently using Gymnasium by importing `import gymnasium as gym` and verify that the environment ID and API calls (e.g., `env.reset(seed=...)` and `env.step(...)` returning `(observation, reward, terminated, truncated, info)`) are compliant with Gymnasium's API (version 0.26.0 and higher). If you specifically need legacy OpenAI Gym behavior, consider using a separate virtual environment with the older `gym` package.
Upgrade
Version history
1.3.0latest on PyPI · released Apr 22, 2026
Audit
Dependencies
numpyrequiredCore dependency for array manipulation in observations and spaces.
box2doptionalRequired for `gymnasium[box2d]` environments (replaces `box2d-py` since v1.2.3).
mujocooptionalRequired for `gymnasium[mujoco]` environments.
Agent activity
22 hits · last 30 days
node
16
OpenAI (training)
1
Resources