- Gymnasium v1.2.2
- Part1 Sample Code
- Part2 Sample Code
- Part3 Sample Code
# 1. Create a virtual environment
python -m venv .venv
# 2. Activate the virtual environment
source .venv/bin/activate
# 3. Navigate to the Gymnasium directory
cd group_project/Gymnasium
# 4. Install Gymnasium in editable mode
pip install -e .
# 5. Install additional dependencies
pip install "gymnasium[classic_control]"
pip install matplotlibRun the following command to verify that the installation is successful:
% pip listSample Output from MacOS:
Package Version Editable project location
-------------------- ------- --------------------------------------------
cloudpickle 3.1.2
Farama-Notifications 0.0.4
gymnasium 1.2.2 ./group_project/Gymnasium
numpy 2.3.5
pip 24.3.1
typing_extensions 4.15.0
If your output matches the above (or is similar), your environment is correctly configured.
Train and test the reinforcement learning agent:
# Train the agent
python mountain_car.py --train --episodes 5000
# Render and visualize performance
python mountain_car.py --render --episodes 10Run the Frozen Lake environment:
python frozen_lake.pyExecute the custom OOP environment:
python oop_project_env.pyTip:
If you’re on Windows, replace
source .venv/bin/activatewith
.venv\Scripts\activate