Farama-Foundation / PettingZoo

An API standard for multi-agent reinforcement learning environments, with popular reference environments and related utilities
https://pettingzoo.farama.org
Other
2.64k stars 419 forks source link

[Bug Report] Rom not found after installing AutoRom #1160

Open MrCley opened 10 months ago

MrCley commented 10 months ago

Describe the bug

When trying to run the Atari examples in the docs, the same error is shown (for all games):

OSError: rom tennis is not installed. Please install roms using AutoROM tool (https://github.com/Farama-Foundation/AutoROM) or specify and double-check the path to your Atari rom using the rom_path argument.

It says that the rom is not installed and suggests installing AutoROM, which is already installed (pip list below).

Full stack trace:

Traceback (most recent call last): File "/Users/mrcley/Documents/py/marl_atari/src/train.py", line 3, in env = tennis_v3.env(render_mode="human") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mrcley/Documents/py/marl_atari/env/lib/python3.11/site-packages/pettingzoo/atari/base_atari_env.py", line 25, in env_fn env = raw_env_fn(kwargs) ^^^^^^^^^^^^^^^^^^^^ File "/Users/mrcley/Documents/py/marl_atari/env/lib/python3.11/site-packages/pettingzoo/atari/tennis/tennis.py", line 91, in raw_env return BaseAtariEnv( ^^^^^^^^^^^^^ File "/Users/mrcley/Documents/py/marl_atari/env/lib/python3.11/site-packages/pettingzoo/atari/base_atari_env.py", line 34, in BaseAtariEnv return parallel_to_aec_wrapper(ParallelAtariEnv(kwargs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mrcley/Documents/py/marl_atari/env/lib/python3.11/site-packages/pettingzoo/atari/base_atari_env.py", line 109, in init raise OSError( OSError: rom tennis is not installed. Please install roms using AutoROM tool (https://github.com/Farama-Foundation/AutoROM) or specify and double-check the path to your Atari rom using the rom_path argument.

Thanks!

Code example

from pettingzoo.atari import tennis_v3

env = tennis_v3.env(render_mode="human")
env.reset(seed=42)

for agent in env.agent_iter():
    observation, reward, termination, truncation, info = env.last()

    if termination or truncation:
        action = None
    else:
        # this is where you would insert your policy
        action = env.action_space(agent).sample()

    env.step(action)
env.close()

System info

M1 macOs Ventura 13.0.1 Python 3.11.6 pip list:

ale-py==0.8.1 AutoROM==0.6.1 AutoROM.accept-rom-license==0.6.1 certifi==2023.11.17 charset-normalizer==3.3.2 click==8.1.7 cloudpickle==3.0.0 Farama-Notifications==0.0.4 gymnasium==0.29.1 idna==3.6 importlib-resources==6.1.1 multi-agent-ale-py==0.1.11 numpy==1.26.3 pettingzoo==1.24.3 pygame==2.3.0 requests==2.31.0 Shimmy==0.2.1 tqdm==4.66.1 typing_extensions==4.9.0 urllib3==2.1.0

Additional context

AutoROM works fine in another project (same Python version) that is not using PettingZoo but is also using Gymnasium 0.29.1.

Checklist

elliottower commented 10 months ago

Can you give the full stack trace? We have testing in our CI for both linux/mac and python 3.8-3.11 which successfully installs the ROMs and tests them, I’ll check what versions are installed there though just to be sure

elliottower commented 10 months ago

Oh what it might be is that we don’t explicitly test on M1 macs currently, but I believe that is now possible in GitHub actions so I could test it out

MrCley commented 10 months ago

@elliottower that was fast! πŸ˜„ I've added the stack trace to the issue description. Thanks for looking into it!

elliottower commented 10 months ago

The tests all passed on the different Mac versions (11, 12, and 13 with m1) so I think it must be something on your end

pseudo-rnd-thoughts commented 10 months ago

Could you rerun pip install "gymnasium[accept-atari-roms]" then run

import gymnasium
gymnasium.make("ALE/Pong-v5")
MrCley commented 10 months ago

Could you rerun pip install "gymnasium[accept-atari-roms]" then run

import gymnasium
gymnasium.make("ALE/Pong-v5")

if I install the gymnasium rom license (pip install 'gymnasium[accept-rom-license]'), and try the make() method, it does create the env.

But using the _tennisv3.env() provided in the docs, it still gives the error provided in the description above.

pseudo-rnd-thoughts commented 10 months ago

@elliottower It seems like ale-py is doing something different from PettingZoo when finding the rom which is part of the issue

jjshoots commented 10 months ago

Adding on, a good place to start debugging this is probably here. I can start looking into this later.

jjshoots commented 9 months ago

@MrCley I've looked into this and for some reason I cannot replicate this. Is this still happening on your end?

MrCley commented 9 months ago

Hi @jjshoots, yes it still happens :(

I've made another project (also Python 3.11), cloned the repo and ran the tests (pip install -e .[testing,all] then pytest -v), they pass except the Atari ones, which fail because of the missing ROM.

jjshoots commented 9 months ago

@MrCley I assume you've done AutoROM -v?

MrCley commented 9 months ago

yes, I ran the tests both before and after running AutoROM -v and got the same results

jjshoots commented 9 months ago

@MrCley I assume you're using some form of virtual env? If so, could you print out the contents of */lib/python3.10/site-packages/multi_agent_ale_py/roms? It should match the following:

ο…› adventure.bin        ο…› fishing_derby.bin      ο…› pitfall.bin
ο…› air_raid.bin         ο…› flag_capture.bin       ο…› pitfall2.bin
ο…› alien.bin            ο…› freeway.bin            ο…› pong.bin
ο…› amidar.bin           ο…› frogger.bin            ο…› pooyan.bin
ο…› assault.bin          ο…› frostbite.bin          ο…› private_eye.bin
ο…› asterix.bin          ο…› galaxian.bin           ο…› qbert.bin
ο…› asteroids.bin        ο…› gopher.bin             ο…› riverraid.bin
ο…› atlantis.bin         ο…› gravitar.bin           ο…› road_runner.bin
ο…› atlantis2.bin        ο…› hangman.bin            ο…› robotank.bin
ο…› backgammon.bin       ο…› haunted_house.bin      ο…› seaquest.bin
ο…› bank_heist.bin       ο…› hero.bin               ο…› sir_lancelot.bin
ο…› basic_math.bin       ο…› human_cannonball.bin   ο…› skiing.bin
ο…› battle_zone.bin      ο…› ice_hockey.bin         ο…› solaris.bin
ο…› beam_rider.bin       ο…› jamesbond.bin          ο…› space_invaders.bin
ο…› berzerk.bin          ο…› journey_escape.bin     ο…› space_war.bin
ο…› blackjack.bin        ο…› joust.bin              ο…› star_gunner.bin
ο…› bowling.bin          ο…› kaboom.bin             ο…› superman.bin
ο…› boxing.bin           ο…› kangaroo.bin           ο…› surround.bin
ο…› breakout.bin         ο…› keystone_kapers.bin    ο…› tennis.bin
ο…› carnival.bin         ο…› king_kong.bin          ο…› tetris.bin
ο…› casino.bin           ο…› klax.bin               ο…› tic_tac_toe_3d.bin
ο…› centipede.bin        ο…› koolaid.bin            ο…› time_pilot.bin
ο…› chopper_command.bin  ο…› krull.bin              ο…› trondead.bin
ο…› combat.bin           ο…› kung_fu_master.bin     ο…› turmoil.bin
ο…› crazy_climber.bin    ο…› laser_gates.bin        ο…› tutankham.bin
ο…› crossbow.bin         ο…› lost_luggage.bin       ο…› up_n_down.bin
ο…› darkchambers.bin     ο…› mario_bros.bin         ο…› venture.bin
ο…› defender.bin         ο…› maze_craze.bin         ο…› video_checkers.bin
ο…› demon_attack.bin     ο…› miniature_golf.bin     ο…› video_chess.bin
ο…› donkey_kong.bin      ο…› montezuma_revenge.bin  ο…› video_cube.bin
ο…› double_dunk.bin      ο…› mr_do.bin              ο…› video_pinball.bin
ο…› earthworld.bin       ο…› ms_pacman.bin          ο…› warlords.bin
ο…› elevator_action.bin  ο…› name_this_game.bin     ο…› wizard_of_wor.bin
ο…› enduro.bin           ο…› othello.bin            ο…› word_zapper.bin
ο…› entombed.bin         ο…› pacman.bin             ο…› yars_revenge.bin
ο…› et.bin               ο…› phoenix.bin            ο…› zaxxon.bin
MrCley commented 9 months ago

hey @jjshoots, just checked and there is no roms folder in there:

Screenshot 2024-02-03 at 15 05 03

jjshoots commented 9 months ago

@MrCley Apologies for the repeated slow responses.

That does not look good... Could you open up a Python interpreter within the venv, and run the following and send the output here?

import importlib.resources as r
r.files("multi_agent_ale_py")
r.files("AutoROM")

Also, could you verify that multi_agent_ale_py is not accidentally installed into the global python environment and only exists in the venv?