Farama-Foundation/Gymnasium
A standard API for single-agent reinforcement learning environments, with popular reference environments and related utilities (formerly Gym)
What is Gymnasium?
Gymnasium is a Python library that provides a standard API for reinforcement‑learning (RL) research. It lets you create, run, and compare RL agents against a wide collection of simulated environments – from simple classic‑control tasks to complex physics‑based or Atari games. It is a community‑maintained fork of OpenAI’s original Gym library, and the place where future updates will be released.
Why it matters
- Uniform interface – All environments expose the same
reset,step,action_space, andobservation_spacemethods, so the same learning code can be swapped across many tasks. - Reproducibility – Environments are versioned (e.g.,
CartPole-v1) and the version number increments whenever a change could affect learning results. - Broad ecosystem – Includes classic control, Box2D, toy text, MuJoCo, Atari, plus many third‑party environments that already follow the Gymnasium API.
- Community support – Documentation site, Discord chat, and a clear contribution guide make it easy for newcomers to get help and for developers to add new environments.
How to get started (code snippet from the README)
import gymnasium as gym
env = gym.make("CartPole-v1")
observation, info = env.reset(seed=42)
for _ in range(1000):
action = env.action_space.sample() # pick a random action
observation, reward, terminated, truncated, info = env.step(action)
if terminated or truncated:
observation, info = env.reset()
env.close()
Create an environment, reset it, take actions, and handle episode termination – all in just a few lines.
Installation
pip install gymnasium # core library only
pip install "gymnasium[atari]" # add Atari dependencies
pip install "gymnasium[all]" # install every optional dependency
(The optional packages are large and sometimes tricky to build, so you can install only what you need.)
Related projects you might also use
| Project | What it adds |
|---|---|
| CleanRL | Simple, reference RL algorithm implementations that use the Gymnasium API. |
| PettingZoo | Multi‑agent extension of Gymnasium with its own set of environments. |
| Farama Foundation environments | Additional curated environments that follow the same API. |
Getting involved
Read the CONTRIBUTING.md for guidelines. Support the project financially via the GitHub Sponsors link if you can.
TL;DR – Gymnasium is the go‑to library for anyone building or testing reinforcement‑learning agents, offering a clean, versioned interface to a huge suite of simulated tasks.
Related
- Project
- Project
- Project
- Project
- Project