Skip to content

Gymnasium

A standard Python interface for reinforcement learning environments, plus reference environments to test algor

Stars
12.8k
Forks
1.5k
Licence
MIT
Language
Python
Last update
7 days ago
Type
Library

What it is

Gymnasium is an open-source Python library that gives reinforcement learning algorithms and simulated environments a shared, standard way to talk to each other. It also includes a set of ready-made environments, such as classic control problems, physics-based games, and Atari games. It is a maintained fork of OpenAI's Gym library.

  • Create a standard environment such as CartPole-v1 and step through it with random actions
  • Train an agent on a Classic Control or Toy Text environment to compare learning methods
  • Run Atari or MuJoCo environments after installing the matching extra dependencies
  • Write your own environment that follows the Gymnasium API so existing algorithms can use it

Great for

  • Researchers comparing reinforcement learning algorithms on the same environments
  • Students learning reinforcement learning with simple, well-known test problems
  • Developers who want an environment API that other tools (such as CleanRL) already support
  • Anyone migrating older Gym code who wants continued maintenance

Not ideal for

  • People who want a finished product rather than code to build on, since it is a library for experiments and research
  • Users who need multi-agent environments, because the README says Gymnasium covers single-agent setups and points to PettingZoo for multi-agent work
  • Those who do not know Python, since the API and examples are Python-only
Step-by-step guide: how to use GymnasiumInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Python

    Install the base library

    pip install gymnasium

    Install dependencies for one environment family (example: Atari)

    pip install "gymnasium[atari]"

    Install dependencies for all environment families

    pip install "gymnasium[all]"
  2. 2

    Run it

    • Install the base library with pip install gymnasium
    • Open a Python session and import gymnasium as gym
    • Create an environment with env = gym.make("CartPole-v1")
    • Call env.reset(seed=42), then loop with env.action_space.sample() and env.step(action)
    • Call env.close() when finished
  3. 3

    Get the most out of it

    • Install only the environment extras you need, since the full install can be large and some dependencies are hard to set up
    • Read the environment documentation at gymnasium.farama.org for details on each family
    • Use CleanRL, which the README describes as built on the Gymnasium API, for reference implementations
    • Use PettingZoo, which the README describes as the multi-agent counterpart, if you need multiple agents

Downloads

Strengths

  • Provides a standard API, so the same agent code can run on many environments
  • Maintained by a team that took over from OpenAI's Gym, with documentation and a Discord community
  • Environment versions are pinned with suffixes like -v1, which helps reproducibility

Trade-offs

  • Installing the base package does not include dependencies for every environment family; some extras can be difficult to install on certain systems
  • Third-party environments may target older API versions and may need the apply_env_compatibility option
  • The README is short on detail for advanced use, so deeper usage depends on the separate documentation site

How it compares

ProjectStarsTypeLevelUpdatedBest for
Gymnasium (this)12.8kLibraryintermediate7 days agoResearchers comparing reinforcement learning algorithms on the same environments
stable-baselines314kLibraryintermediate11 days agoResearchers who want a reliable baseline to compare a new method against
annotated_deep_learning_paper_implementations67.6kLearning resourceintermediate4 days agoStudents learning how transformers, GANs, or optimizers work internally
applied-ml30.8kCurated listbeginner2.3 years agoEngineers planning an ML project who want to see how other companies approached a similar problem
ItChat26.5kLibraryintermediate3.1 years agoPython developers who want to script a personal WeChat account
FinGPT21.5kAI model / agentadvanced12 days agoDevelopers who want to experiment with finance-tuned LLMs for sentiment analysis

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.