# Safety-Gymnasium standardizes constrained RL on MuJoCo, but you install it from a zip file

> Safety-Gymnasium is an Apache-2.0 benchmark of safe reinforcement learning environments from the PKU-Alignment group, with a Gymnasium compatible API for constraint information. Its environment set is current enough to need Python 3.10, while its documented install path still points at Python 3.8 and a manually downloaded archive.

**PKU-Alignment/safety-gymnasium** — NeurIPS 2023: Safety-Gymnasium: A Unified Safe Reinforcement Learning Benchmark

- Repository: https://github.com/PKU-Alignment/safety-gymnasium
- Website: https://safety-gymnasium.readthedocs.io/en/latest/
- Stars: 593 · Forks: 80
- Language: Python
- License: Apache-2.0
- Published: 2026-10-22 · Updated: 2026-10-22 · Language: en
- Canonical page: https://hysenlabs.com/projects/pku-alignment-safety-gymnasium

## The library exists to make SafeRL results comparable

Safety-Gymnasium is described as a highly scalable and customizable safe reinforcement learning library, and the goal is stated as delivering a good view of benchmarking SafeRL algorithms together with a standardized set of environments. The set of standard APIs is compatible with information on constraints, which is the part that matters most for a benchmark. In safe reinforcement learning the interesting question is not only what reward an agent collects but how well it stays inside a constraint, and comparing algorithms across papers only means something if the constraint signal is exposed the same way in every environment. The project also lists a comparison table against existing SafeRL environment libraries, comparing engine, whether the environments are vectorized, whether the new Gym API is used, and whether vision input is supported. The table is cut off in what is published, but the rows that are visible already show the axis that separates these libraries, which is that most of the earlier ones run on their own engine, are not vectorized, and do not use the new Gym API. The project was presented at NeurIPS 2023 in the Datasets and Benchmarks Track.

## Installation is a manual archive, not a pip install

This is the part that will cost an afternoon if you assume otherwise. The README carries a prominent note for versions 1.1.0 and 1.2.0. The environments for both the Safe Vision series and the Safe Isaac Gym series were updated, but due to package size constraints those two versions have not been uploaded to PyPI. Users are required to manually download and install, and the recommendation is to use GitHub's Download zip feature to obtain the package and access the latest environments. The documented sequence is a conda environment on Python 3.8, an unzip of the downloaded archive, and an editable install.

```bash
conda create -n example python=3.8
conda activate example
wget https://github.com/PKU-Alignment/safety-gymnasium/archive/refs/heads/main.zip
unzip main.zip
cd safety-gymnasium-main
pip install -e .
```

There is a second constraint in the same note, and it conflicts with the dependency list. The README says Python 3.11 is not supported for now, due to the incompatibility of pygame, and the install snippet pins 3.8. The package metadata is more permissive, requiring Python 3.8 or newer and listing classifiers for 3.8 through 3.11, and it pins pygame at 2.1.0, which is where the incompatibility comes from. So the safe reading is that the code nominally accepts 3.9, 3.10 and 3.11 while the environment creation the project tells you to use stays on 3.8.

## The dependency set pins the simulation stack tightly

The dependency list explains a lot about the shape of the project. gymnasium is pinned at exactly 0.28.1 and gymnasium-robotics at 1.2.2, which is the new Gym API the comparison table complains the other libraries lack. mujoco is pinned at 2.3.3, and mujoco-py is not among the dependencies at all, which is the switch from the older MuJoCo Python binding to the newer one that Safety-Gym itself used. xmltodict at 0.13.0 or newer is there to read and write the MJCF XML scene descriptions, and pyyaml, imageio and pygame complete the set. The exact pins are the norm for a benchmark, because a version drift in the simulator changes the physics and therefore changes the numbers an algorithm produces. The price of that reproducibility is that you cannot simply take a newer gymnasium or mujoco when you need a fix, and you inherit the pinned set whether or not it suits your own stack. The optional dependency groups are development oriented rather than functional, with lint covering isort, black, pylint, mypy and a set of flake8 plugins.

## The package layout separates the library from the agent code

The repository structure tells you what is the library and what is around it. The safety_gymnasium/ directory is the package itself, with setup.py and pyproject.toml at the root, and the version is read from safety_gymnasium/version.py at install time. That setup.py is worth reading because it does something unusual: it rewrites the __version__ line in version.py at build time and restores the original file afterwards, in a try and finally block, so a release build stamps the version without leaving the working tree dirty. The Makefile is a developer convenience with install, install-editable, uninstall and build targets, and it also carries the tool installation targets for the lint stack. The examples/ directory holds the scripts a new user would read first, and the names describe the range of what the library supports: env.py, env_from_config.py, multi_agent_env.py, multi_goal.py and vision_env.py. A separate vision environment, a multi-agent environment, a multi-goal environment and an environment built from a config file are four different surfaces, and the presence of the config example is a good sign that environment definition is meant to be data rather than code.

## The comparison table is the project's argument, and it is truncated

The Why Safety-Gymnasium section is a single table comparing the library with existing SafeRL environment libraries, and it is the most interesting part of the README. The visible rows are Safety-Gym on the mujoco-py engine, safe-control-gym on PyBullet, Velocity-Constraints with no engine listed, and mujoco-circle on PyTorch. Against each, the columns record vectorized environments, the new Gym API, and vision input support, and the visible entries are almost entirely marked with a cross. Safety-Gym itself is described as minimally supporting vision input. So the claim being made is that this library is the one that scales the environments, uses the current API, and actually supports vision, while the alternatives are single-engine, single-process and largely blind. Two cautions. The table is truncated in the published README, so the full comparison and any footnote explaining the markers cannot be read, and the footnotes on the table, which the header references with superscripts, are not visible either. And a comparison written by the project about itself is a claim, not a measurement, so treat it as a map of the design space rather than as evidence.

## Where a different tool is the better answer

There are situations where this library is the wrong shape of choice. If you need environments that simulate people rather than robots, the constraint formulation in safe RL literature, with velocity constraints on a moving agent, is not what a safety critical system designer needs, and you would be bending a research benchmark into a shape it was not designed for. If your requirement is a maintained stream of new tasks and new simulators, the release history argues against it, since the newest tagged versions are 1.0.0, 1.1.0 and 1.2.0 from 2023 and the environments have been updated since without a PyPI release. If you want a plain reinforcement learning environment with no constraint machinery at all, the constraint API and the extra observation handling are overhead. There is also a straightforward alternative for the benchmarking goal itself, which is to use a plain Gymnasium environment and implement the constraint as part of the reward and the observation space yourself. That is more work, and it is exactly the work the benchmark exists to standardise, which is the argument for using the library and also the argument for how much you are trusting it. For algorithms with their own safety machinery, such as Lagrangian methods, the constraint information the library exposes is the interface they need.

## Conclusion

Safety-Gymnasium suits researchers who need a common set of constrained reinforcement learning environments and a shared API for constraint data, and it suits teams reproducing the NeurIPS 2023 benchmark. It does not suit a production deployment that expects a normal pip install, since the two most recent versions are not on PyPI and the documented environment creation still uses Python 3.8, and it does not suit work that needs a maintained stream of new tasks. Before adopting it, download the main branch archive, create the environment with the Python version the README specifies, and check that your algorithm implements the constraint information interface the library expects.

## FAQ

### How do I install Safety-Gymnasium?

Versions 1.1.0 and 1.2.0 are not on PyPI because of package size constraints, so the documented path is to download the GitHub archive, create a conda environment on Python 3.8, unzip it, and run pip install -e . inside the extracted directory.

### Does Safety-Gymnasium support Python 3.11?

Not for now, because of the incompatibility of pygame, which the project pins at version 2.1.0. The README's install instructions use Python 3.8 even though the package metadata lists classifiers up to 3.11.

### What is the API for constraint information in Safety-Gymnasium?

The project provides a set of standard APIs that are compatible with information on constraints, so that safe reinforcement learning algorithms can read the constraint signal the same way in every environment. That shared interface is the point of the benchmark.

### What simulation engine does Safety-Gymnasium use?

It uses MuJoCo, pinned at version 2.3.3 in the dependencies, along with gymnasium 0.28.1 and gymnasium-robotics 1.2.2, xmltodict for the MJCF scene files, and pygame 2.1.0 for rendering.

### What licence is Safety-Gymnasium released under?

The project is licensed under the Apache License, Version 2.0, recorded in the LICENSE file and in the package metadata, with the source files carrying the OmniSafe Team copyright header.

## Sources

- [License: Apache-2.0](https://github.com/PKU-Alignment/safety-gymnasium/blob/main/LICENSE)
- [PKU-Alignment/safety-gymnasium on GitHub](https://github.com/PKU-Alignment/safety-gymnasium)
- [Project website](https://safety-gymnasium.readthedocs.io/en/latest/)
- [README](https://github.com/PKU-Alignment/safety-gymnasium/blob/main/README.md)
- [Releases](https://github.com/PKU-Alignment/safety-gymnasium/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/pku-alignment-safety-gymnasium
