Skip to content

KeyError: 'render_modes' raised by gym_super_mario_bros.make('SuperMarioBros-v0') #116

@andreaskopp

Description

@andreaskopp

Describe the bug

The sample code on https://pypi.org/project/gym-super-mario-bros/ raises KeyError: 'render_modes' with latest install

Reproduction Script

install:
pip install gym-super-mario-bros

code:
from nes_py.wrappers import JoypadSpace
import gym_super_mario_bros
from gym_super_mario_bros.actions import SIMPLE_MOVEMENT
env = gym_super_mario_bros.make('SuperMarioBros-v0')
env = JoypadSpace(env, SIMPLE_MOVEMENT)

done = True
for step in range(5000):
if done:
state = env.reset()
state, reward, done, info = env.step(env.action_space.sample())
env.render()

env.close()

Expected behavior

Code should execute without error

Screenshots


KeyError Traceback (most recent call last)
Input In [1], in <cell line: 4>()
2 import gym_super_mario_bros
3 from gym_super_mario_bros.actions import SIMPLE_MOVEMENT
----> 4 env = gym_super_mario_bros.make('SuperMarioBros-v0')
5 env = JoypadSpace(env, SIMPLE_MOVEMENT)
7 done = True

File ~\Miniconda3\envs\rlgames\lib\site-packages\gym\envs\registration.py:625, 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"]
627 # We might be able to fall back to the HumanRendering wrapper if 'human' rendering is not supported natively
628 if (
629 mode == "human"
630 and "human" not in render_modes
631 and ("single_rgb_array" in render_modes or "rgb_array" in render_modes)
632 ):

KeyError: 'render_modes'

Additional context

Using Windows 11, Python 3.8 in Conda env

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions