题意:尝试导入OpenAI Gym库中的某个环境时发生了错误
问题背景:
I am trying to run an OpenAI Gym environment however I get the following error:
我正在尝试运行一个OpenAI Gym环境,但是我遇到了以下错误:
import gym
env = gym.make('Breakout-v0')
ERROR 错误
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ale_py/gym/environment.py:11: DeprecationWarning: Importing atari-py roms won't be supported in future releases of ale-py.
import ale_py.roms as roms
A.L.E: Arcade Learning Environment (version +a54a328)
[Powered by Stella]
Traceback (most recent call last):
File "/Users/username/Desktop/OpenAI Gym Stuff/OpenAI_Exp.py", line 2, in <module>
env = gym.make('Breakout-v0')
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/gym/envs/registration.py", line 200, in make
return registry.make(id, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/gym/envs/registration.py", line 105, in make
env = spec.make(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/gym/envs/registration.py", line 75, in make
env = cls(**_kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ale_py/gym/environment.py", line 123, in __init__
self.seed()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ale_py/gym/environment.py", line 171, in seed
raise error.Error(
gym.error.Error: Unable to find game "Breakout", did you import Breakout with ale-import-roms?
问题解决:
Code works for me with gym
0.18.0
and 0.19.0
but not with 0.20.0
我的代码在gym 0.18.0和0.19.0版本上可以工作,但在0.20.0版本上不行。
You may downgrade it with 你可以使用以下代码降级
pip install --upgrade gym==0.19.0
BTW: it may also need to install gym[atari]
or gym[all]
to have all elements to work.
顺便说一句:为了所有元素都能正常工作,可能还需要安装 gym[atari] 或 gym[all]。
Base on information in Release Note for 0.21.0 (which is not ready on pip
but you can install from GitHub) there was some change in ALE
(Arcade Learning Environment
) and it made all problem but it is fixed in 0.21.0
.
基于0.21.0版本的发布说明(该版本尚未在pip上准备好,但你可以从GitHub安装)中的信息,Arcade Learning Environment(ALE,街机学习环境)进行了一些更改,这导致了一些问题,但这些问题在0.21.0版本中已经被修复了。
-The old Atari entry point that was broken with the last release and the upgrade to ALE-Py is fixed
But new gym[atari]
not installs ROMs and you will need to use module AutoROM
但是新的 gym[atari] 安装包并不包含ROM文件,你需要使用模块(或某种方式)来
-pip install gym[atari] no longer distributes Atari ROMs that the ALE (the Atari emulator used) needs to run the various games. The easiest way to install ROMs into the ALE has been to use AutoROM.
EDIT:
Version 0.21.0
from GitHub works for me after installing
从GitHub上下载了Gym库的0.21.0版本,并且安装后它能够在你的环境中正常工作
(it may need program git
for it)
pip install --upgrade git+https://github.com/openai/gym
pip install autorom
AutoRom
pip install --upgrade gym[atari]
AutoRom runs program which asks if you have license for ROMs and install ROMs in AutoROM/roms
but I didn't have to move ROMs to other place.
运行程序会询问你是否拥有ROM的许可证,并在AutoROM/roms目录下安装ROM,但我不需要将ROM移动到其他位置。
AutoROM will download the Atari 2600 ROMs.
They will be installed to:
/usr/local/lib/python3.8/dist-packages/AutoROM/roms
Existing ROMs will be overwritten.
I own a license to these Atari 2600 ROMs.
I agree to not distribute these ROMs and wish to proceed: [Y/n]:
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/adventure.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/air_raid.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/alien.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/amidar.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/assault.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/asterix.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/asteroids.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/atlantis.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/atlantis2.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/backgammon.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/bank_heist.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/basic_math.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/battle_zone.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/beam_rider.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/berzerk.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/blackjack.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/bowling.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/boxing.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/breakout.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/carnival.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/casino.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/centipede.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/chopper_command.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/combat.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/crazy_climber.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/crossbow.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/darkchambers.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/defender.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/demon_attack.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/donkey_kong.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/double_dunk.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/earthworld.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/elevator_action.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/enduro.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/entombed.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/et.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/fishing_derby.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/flag_capture.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/freeway.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/frogger.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/frostbite.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/galaxian.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/gopher.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/gravitar.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/hangman.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/haunted_house.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/hero.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/human_cannonball.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/ice_hockey.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/jamesbond.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/journey_escape.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/joust.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/kaboom.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/kangaroo.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/keystone_kapers.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/king_kong.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/klax.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/koolaid.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/krull.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/kung_fu_master.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/laser_gates.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/lost_luggage.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/mario_bros.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/maze_craze.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/miniature_golf.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/montezuma_revenge.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/mr_do.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/ms_pacman.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/name_this_game.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/othello.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/pacman.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/phoenix.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/pitfall.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/pitfall2.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/pong.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/pooyan.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/private_eye.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/qbert.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/riverraid.bin
Installed /usr/local/lib/python3.8/dist-packages/AutoROM/roms/road_runner.bin
Installed
After installation this code works for me without error and without DeprecationWarning
.
安装后,这段代码对我来说可以无误运行,没有出现弃用警告(DeprecationWarning)。
import gym
import ale_py
print('gym:', gym.__version__)
print('ale_py:', ale_py.__version__)
env = gym.make('Breakout-v0')
and it gives 反馈如下
gym: 0.21.0
ale_py: 0.7.1
A.L.E: Arcade Learning Environment (version +b7b0c1a)
[Powered by Stella]