我试图遵循尼古拉斯雷诺特教程“用Python构建一个带有Python游戏强化学习的Mario模型”,并且无法在错误的基础上移动。
这是我的代码:
!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')引发以下错误:
---------------------------------------------------------------------------
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,并重新安装软件包
发布于 2022-07-17 15:41:02
大多数自定义env尚未为0.25版本做好准备。将版本改为0.24.1应能解决这一问题。
尝试:
pip install gym=0.24.1亲切的问候
https://stackoverflow.com/questions/73011621
复制相似问题