首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我在创建gym_super_mario_bros env时遇到了问题,KeyError:'render_modes‘

我在创建gym_super_mario_bros env时遇到了问题,KeyError:'render_modes‘
EN

Stack Overflow用户
提问于 2022-07-17 12:05:59
回答 1查看 813关注 0票数 2

我试图遵循尼古拉斯雷诺特教程“用Python构建一个带有Python游戏强化学习的Mario模型”,并且无法在错误的基础上移动。

这是我的代码:

代码语言:javascript
复制
!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)

这一行代码:env = gym_super_mario_bros.make('SuperMarioBros-v0')引发以下错误:

代码语言:javascript
复制
---------------------------------------------------------------------------
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'

我已经尝试使用python3.7而不是3.9,并重新安装软件包

EN

Stack Overflow用户

发布于 2022-07-17 15:41:02

大多数自定义env尚未为0.25版本做好准备。将版本改为0.24.1应能解决这一问题。

尝试:

代码语言:javascript
复制
pip install gym=0.24.1

亲切的问候

票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73011621

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档