I have a problem with creating gym_super_mario_bros env and have KeyError: 'render_modes'

Viewed 597

I'm trying to follow "Build an Mario AI Model with Python | Gaming Reinforcement Learning" by Nicholas Renotte tutorial and can't move on beacouse of some error.

Here is my code:

!pip install gym_super_mario_bros==7.3.0 nes_py

# Import the game
import gym_super_mario_bros
# Import the Joypad wrapper
from nes_py.wrappers import JoypadSpace
# Import the simplified controls
from gym_super_mario_bros.actions import SIMPLE_MOVEMENT

# Setup game
env = gym_super_mario_bros.make('SuperMarioBros-v0')
env = JoypadSpace(env, SIMPLE_MOVEMENT)
   

and this line of code: env = gym_super_mario_bros.make('SuperMarioBros-v0') couses following error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_16900\3897944130.py in <module>
      1 # Setup game
----> 2 env = gym_super_mario_bros.make('SuperMarioBros-v0')
      3 env = JoypadSpace(env, SIMPLE_MOVEMENT)

D:\Anaconda\envs\gamesAi\lib\site-packages\gym\envs\registration.py in make(id, max_episode_steps, autoreset, new_step_api, disable_env_checker, **kwargs)
    623     # If we have access to metadata we check that "render_mode" is valid
    624     if hasattr(env_creator, "metadata"):
--> 625         render_modes = env_creator.metadata["render_modes"]
    626 
    627         # We might be able to fall back to the HumanRendering wrapper if 'human' rendering is not supported natively

KeyError: 'render_modes'


I've already tried using python 3.7 instead of 3.9 and reinstalling packages

1 Answers

Most of the custom envs are not yet ready for the 0.25 Version. Changing the version to 0.24.1 should solve the issue.

Try:

pip install gym=0.24.1

Kind regards

Related