Skip to content

fix: migrate from gym to gymnasium for NumPy 2.0+ compatibility#2108

Open
Ayush10 wants to merge 1 commit intomicrosoft:mainfrom
Ayush10:fix/issue-2018-gym-to-gymnasium
Open

fix: migrate from gym to gymnasium for NumPy 2.0+ compatibility#2108
Ayush10 wants to merge 1 commit intomicrosoft:mainfrom
Ayush10:fix/issue-2018-gym-to-gymnasium

Conversation

@Ayush10
Copy link

@Ayush10 Ayush10 commented Jan 30, 2026

Summary

Closes #2018

Replace the unmaintained gym package with gymnasium, its actively maintained drop-in replacement. The gym package has been unmaintained since 2022 and does not support NumPy 2.0+, causing hard crashes when running backtests.

Changes

  • Replace import gym with import gymnasium as gym in all RL source files (5 files)
  • Replace from gym import with from gymnasium import in all files
  • Update pyproject.toml dependency from gym to gymnasium
  • Update test files (3 files) to use gymnasium imports

Test Plan

  • All import statements updated across 8 files
  • pyproject.toml dependency updated
  • API is drop-in compatible (spaces, Env, etc. unchanged)
  • tianshou<=0.4.10 compatibility preserved (old-style API)

…osoft#2018)

Replace the unmaintained `gym` package with `gymnasium`, its actively
maintained drop-in replacement. This fixes crashes when running with
NumPy 2.0+ since gym does not support it.

Changes:
- Replace `import gym` with `import gymnasium as gym` in all RL modules
- Replace `from gym import` with `from gymnasium import` in all files
- Update pyproject.toml dependency from `gym` to `gymnasium`
@Ayush10 Ayush10 force-pushed the fix/issue-2018-gym-to-gymnasium branch from b031440 to fd76107 Compare January 30, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Critical Bug: Backtest Module Crash Due to Gym Dependency and NumPy 2.0+ Incompatibility​

1 participant