Registry / ai-ml / pettingzoo

pettingzoo

JSON →
library1.26.1pypypiunverified

PettingZoo is a Python library providing a standardized API for multi-agent reinforcement learning (MARL) environments, analogous to Gymnasium for single-agent RL. It offers a wide variety of reference environments and utilities, supporting both sequential (AEC) and simultaneous (Parallel) action paradigms. Currently at version 1.25.0, the library is actively maintained with frequent updates to ensure compatibility with recent Python and Gymnasium versions.

pip install pettingzoo
INSTALL
IMPORT
SIG · PETTINGZOO
P
pettingzoo
ai-mlpythonv1.26.1
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.26.1 · 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
4/16 runs
12/16 runs
py 3.11
4/16 runs
12/16 runs
py 3.12
4/16 runs
12/16 runs
py 3.13
4/16 runs
8/16 runs
py 3.9
4/16 runs
12/16 runs
Code
Verified usage

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

pistonball_v6
from pettingzoo.butterfly import pistonball_v6
from pettingzoo.butterfly import pistonball_v6

This example demonstrates how to initialize and interact with a PettingZoo environment using the Agent-Environment Cycle (AEC) API, which is suitable for turn-based or sequentially acting multi-agent systems. It uses the `pistonball_v6` environment, renders it to a human-readable window, resets it with a fixed seed for reproducibility, and then steps through agents until the episode terminates or truncates.

from pettingzoo.butterfly import pistonball_v6 env = pistonball_v6.env(render_mode="human") env.reset(seed=42) for agent in env.agent_iter(): observation, reward, terminated, truncated, info = env.last() if terminated or truncated: action = None else: # In a real scenario, this would be your policy's action action = env.action_space(agent).sample() env.step(action) env.close()
Debug
Known issues
breakingPython 3.8 is no longer supported starting from PettingZoo 1.25.0. Ensure your Python environment is 3.9 or higher.
fix
Upgrade Python to a supported version (3.9, 3.10, 3.11, or 3.12).
affects: >=1.25.0
deprecatedThe `pettingzoo.mpe` environments are being transferred to a new dedicated `MPE2` package and will be removed from PettingZoo in a future release.
fix
Update your imports to `mpe2` (e.g., `from mpe2 import simple_spread_v3`) once the `MPE2` package is stable and available.
affects: >=1.25.0
breakingThe `env.seed()` method has been removed to align with Gymnasium API. Seeding is now handled by the `env.reset()` method.
fix
Replace calls to `env.seed(seed)` with `env.reset(seed=seed)`.
affects: >=1.23.0
breakingThe `return_info` argument has been removed from `env.reset()`. Info is now always returned as the second element of the tuple, consistent with Gymnasium.
fix
Remove `return_info=True` or `return_info=False` from `env.reset()` calls. Access info directly from the returned tuple: `observation, info = env.reset(seed=42)`.
affects: >=1.23.0
breakingThe `agent_selector` class was renamed to `AgentSelector` (capitalization change).
fix
Update imports and references to `AgentSelector` if you are directly using this utility class.
affects: >=1.25.0
gotchaWindows support is not officially maintained, though PRs related to Windows are accepted. Users on Windows may encounter installation or runtime issues, especially with environment dependencies.
fix
Prefer Linux or macOS for development. If on Windows, be prepared to troubleshoot environment-specific dependencies (e.g., `cmake`, `swig`).
affects: All
breakingPettingZoo 1.22.4 was yanked from PyPI due to breaking API changes that were accidentally included. Users on this specific version should upgrade.
fix
Upgrade PettingZoo to a later stable version (e.g., `pip install pettingzoo>=1.23.0`).
affects: 1.22.4
Upgrade
Version history
1.26.1latest on PyPI · released Apr 27, 2026
Audit
Dependencies
pythonrequiredSupported versions: 3.9, 3.10, 3.11, 3.12
gymnasiumrequiredCore API dependency, requires >=1.0.0 since PettingZoo 1.25.0
agilerloptionalTutorials/integrations exist, requires >=2.0.0 since PettingZoo 1.25.0
shimmyoptionalCompanion library for compatibility with other ecosystems (e.g., OpenAI Gym, OpenSpiel)
supersuitoptionalCompanion library for common wrappers (frame stacking, observation normalization, vectorization)
Agent activity
13 hits · last 30 days
node
12
Amazon
1
Resources
pettingzoo — pip install pettingzoo · libregistry