Skip to content

Conversation

ishanrajsingh
Copy link

@ishanrajsingh ishanrajsingh commented Sep 26, 2025

  • Replace gym dependency with gymnasium (maintained drop-in replacement)
  • Update all gym imports to use gymnasium
  • Add proper error handling for missing gymnasium dependency
  • Add lazy loading of gymnasium in backtest module
  • Fix hard crashes when using NumPy 2.0+

Fixes #2018

Description

Motivation and Context

How Has This Been Tested?

  • Pass the test by running: pytest qlib/tests/test_all_pipeline.py under upper directory of qlib.
  • If you are adding a new feature, test on your own test scripts.

Screenshots of Test Results (if appropriate):

  1. Pipeline test:
  2. Your own tests:

Types of changes

  • Fix bugs
  • Add new feature
  • Update documentation

- Replace gym dependency with gymnasium (maintained drop-in replacement)
- Update all gym imports to use gymnasium
- Add proper error handling for missing gymnasium dependency
- Add lazy loading of gymnasium in backtest module
- Fix hard crashes when using NumPy 2.0+

Fixes microsoft#2018
@ishanrajsingh
Copy link
Author

@microsoft-github-policy-service agree

- Replace gym dependency with gymnasium (maintained drop-in replacement)
- Update all gym imports to use gymnasium
- Add proper error handling for missing gymnasium dependency
- Add lazy loading of gymnasium in backtest module
- Fix hard crashes when using NumPy 2.0+
- Reformatted code with black for consistency

Fixes microsoft#2018
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