无法通过 Gymnasium 导入 Atari 环境

问题描述 投票:0回答:2

我正在尝试使用 ALE 来测试 Atari 游戏与体育馆。我正在使用下面的代码来创建 Breakout 环境。


import gymnasium as gym
env = gym.make('ALE/Breakout-v5')
done = False
while not done:
    _, _, done, _ = env.step(env.action_space.sample())
    env.render()
env.close()

当我运行此代码时,它返回以下错误:

Error: We're Unable to find the game "Breakout". Note: Gymnasium no longer distributes ROMs. If you own a license to use the necessary ROMs for research purposes you can download them via `pip install gymnasium[accept-rom-license]`. Otherwise, you should try importing "Breakout" via the command `ale-import-roms`. If you believe this is a mistake perhaps your copy of "Breakout" is unsupported. To check if this is the case try providing the environment variable `PYTHONWARNINGS=default::ImportWarning:ale_py.roms`. For more information see: https://github.com/mgbellemare/Arcade-Learning-Environment#rom-management

我的体育馆版本是:0.29.1 我的 ALE 版本是:0.8.1

我已按照体育馆文档中的步骤进行操作,但出现了此问题。有人有什么想法吗?

python reinforcement-learning openai-gym
2个回答
1
投票
从gymnasium网站的atari环境描述

这里,它说你需要先运行命令安装ROM许可证。

pip install gymnasium[accept-rom-licence]
    

0
投票
我使用 Python 3.8 和 3.11 创建了一个新的 conda 环境来重现您的结果。这对我来说效果很好。

pip install gymnasium -> Successfully installed farama-notifications-0.0.4 gymnasium-0.29.1 pip install gymnasium[atari] -> Successfully installed ale-py-0.8.1 shimmy-0.2.1 pip install gymnasium[accept-rom-license] -> Successfully installed AutoROM.accept-rom-license-0.6.1 autorom-0.4.2


您的错误消息已重现...
当我尝试运行您的代码

之前安装最后一行时,重现了您的错误消息:pip install gymnasium[accept-rom-license]

确保...
确保所有命令行都包含

gymnasium

,而不是 
gym


下面是我针对您的问题的测试代码,效果很好。希望和你一样。

import gymnasium as gym; print(f'Gymnasium v{gym.__version__}') env = gym.make('ALE/Breakout-v5', render_mode='rgb_array') env.metadata['render_fps'] = 60 env.reset() done = False while not done: _, _, done, _, _ = env.step(env.action_space.sample()) env.render() env.close()
输出

>> Gymnasium v0.29.1
    
© www.soinside.com 2019 - 2024. All rights reserved.