Reputation: 132
I am totally new to OpenAi gym, I have just installed gym and then try to make environment for
env = gym.make('MsPacman-v0')
so I am getting the following error:
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-21-e04adf623175> in <module>
----> 1 env = gym.make('MsPacman-v0')
~\Anaconda3\envs\env_project\lib\site-packages\gym\envs\registration.py in make(id, **kwargs)
~\Anaconda3\envs\env_project\lib\site-packages\gym\envs\registration.py in make(self, path, **kwargs)
~\Anaconda3\envs\env_project\lib\site-packages\gym\envs\registration.py in make(self, **kwargs)
~\Anaconda3\envs\env_project\lib\site-packages\gym\envs\atari\atari_env.py in __init__(self, game,
mode, difficulty, obs_type, frameskip, repeat_action_probability, full_action_space)
~\Anaconda3\envs\env_project\lib\site-packages\atari_py\games.py in get_game_path(game_name)
18 path = os.path.join(_games_dir, game_name) + ".bin"
19 if not os.path.exists(path):
---> 20 raise Exception('ROM is missing for %s, see https://github.com/openai/atari-py#roms
for instructions' % (game_name,))
21 return path
22
Exception: ROM is missing for ms_pacman, see https://github.com/openai/atari-py#roms for instructions
After this I also tried to find the solution on the web and download the ROMs then hit the command python -m atari_py.import_roms <path where ROMs downloaded>
, after running this command I am also getting following error
(env_project) C:\Users\ME>python -m atari_py.import_roms C:\Users\ME\Downloads\roms_folder\
copying adventure.bin from HC ROMS/BY ALPHABET (PAL)/A-G/Adventure (PAL).bin to
C:\Users\ME\Anaconda3\envs\env_project\lib\site-packages\atari_py\atari_roms\adventure.bin
Traceback (most recent call last):
File "C:\Users\ME\Anaconda3\envs\env_project\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\ME\Anaconda3\envs\env_project\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\ME\Anaconda3\envs\env_project\lib\site-packages\atari_py\import_roms.py", line 93,
in <module>
main()
File "C:\Users\ME\Anaconda3\envs\env_project\lib\site-packages\atari_py\import_roms.py", line 89,
in main
import_roms(args.dirpath)
File "C:\Users\ME\Anaconda3\envs\env_project\lib\site-packages\atari_py\import_roms.py", line 78,
in import_roms
_check_zipfile(f, save_if_matches)
File "C:\Users\ME\Anaconda3\envs\env_project\lib\site-packages\atari_py\import_roms.py", line 23,
in _check_zipfile
process_f(innerf)
File "C:\Users\ME\Anaconda3\envs\env_project\lib\site-packages\atari_py\import_roms.py", line 67,
in save_if_matches
f.seek(0)
io.UnsupportedOperation: seek
I don't know what I am doing wrong. Thank in advance.
Upvotes: 3
Views: 13943
Reputation: 455
import gym is not enough to install if you want to use atari. You must do: pip install "gym[atari,accept-rom-license]"
Upvotes: 0
Reputation: 53
You do not need to download ROM files yourself if you are using atari_py nor if you are using the ale-py (which you are not) but something to have in mind. All ROM files are in directory <drive>\<content root>\venv\Lib\site-packages\atari_py\atari_roms
and they are automatically uploaded when you import atari_py (given it is a working and compatible version)
You should also test if GYM is working for non-atari games as gym (depending on version) imports the games in a different way: (example for GYM 0.18.0, where when it searches for Atari ROM it first goes to Atari in GYM and then it is redirected to atari_py library - so you need to have both)
I just had an issue like this myself. I am using atari_py 0.2.6 (as newer versions of it do not work), Python 3.7 (as atari_py is compatible only with 3.7 and lower of Python), gym 0.18 (as otherwise it is having issues accessing ROM files and loading games, the new GYM version 0.20 (uses games v5) and above uses ale-py and it has a different format for rendering as well - https://brosa.ca/blog/ale-release-v0.7 so games v0 - v4 will not work on it as they have been depicted (or they at least did not work for me) Since your code is looking for the ROM file in atari_py you deff have gym 0.18.0 (lower than 0.20.0 certainly) as the new GYM version uses Ale-py.
(I am not saying your issue is with directory but if you cannot work out where it searches for the ROM files and if it actually exists I advise you to try bellow)
One option you can do is import the library so it is in your directory that your code is in (copy the atari_py folder from github and insert in your directory so it is in content root):
, next you can change (so it can find the directory of the folder the code is executed in):
My advise is to carefully check your versions and compatibility and see if it searches in the right directory for the ROM files and your program should work. Having in mind the directory for imported atari_py 0.2.6 is <drive>\<content root>\venv\Lib\site-packages\atari_py\atari_roms
Upvotes: 0
Reputation: 48456
This is probably due to a bug in ZipFile.seek()
in Python 3.7.0: Python issue #34035.
You need to upgrade to the latest Python 3.7.x release.
Also note that, since gym 0.21, you can install gym and get all the ROMs automatically by running the following commands:
pip install "gym[atari,accept-rom-license]"
Details:
The accept-rom-license
option will install the AutoROM
package, which gives you the AutoROM
command. It will also run it automatically with the --accept-license
option. Alternatively, you could pip install autorom
and run the AutoROM
command manually. If you don't give it any options, this is what it outputs, so be warned. My feeling is that it's okay to use them for research and educational purposes, but I'm not a lawyer:
AutoROM will download the Atari 2600 ROMs.
They will be installed to:
[...]/site-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]:
Run AutoROM --help
for more options.
Upvotes: 2
Reputation: 637
This script should fix the issue
import urllib.request
urllib.request.urlretrieve('http://www.atarimania.com/roms/Roms.rar','Roms.rar')
!pip install unrar
!unrar x Roms.rar
!mkdir rars
!mv HC\ ROMS.zip rars
!mv ROMS.zip rars
!python -m atari_py.import_roms rars
Upvotes: 7
Reputation: 132
After downloading ROMs it will be available as Roms.rar
in Downloads folder, it contains 2 zip files inside HC ROMS.zip
and ROMS.zip
I had to extract Roms.rar
again extracted ROMS.zip
. And then run the command.
python -m atari_py.import_roms C:\Users\ME\Downloads\Roms\ROMS
Upvotes: 3