0

I'm trying to get the Atari environments from Petting Zoo working: https://www.pettingzoo.ml/. I've installed the AutoROMs and I can see the multiple .bin files from all the environments in the directory where the ROMs are installed. However, when I run the following code

import gym, supersuit
from pettingzoo.atari import boxing_v2

path = '/home/myname/miniconda/envs/gym/lib/python3.8/site-packages/multi_agent_ale_py/roms'
env = boxing_v2.env(obs_type='rgb_image', full_action_space=True, max_cycles=100000, auto_rom_install_path=path)

I get the following error:

Traceback (most recent call last):
  File "testingboxingpettingzoo.py", line 5, in <module>
    env = boxing_v2.env(obs_type="rgb_image", full_action_space=True, max_cycles=100000, auto_rom_install_path=path)
  File "/home/myname/miniconda3/envs/gym/lib/python3.8/site-packages/pettingzoo/atari/base_atari_env.py", line 19, in env_fn
    env = raw_env_fn(**kwargs)
  File "/home/myname/miniconda3/envs/gym/lib/python3.8/site-packages/pettingzoo/atari/boxing/boxing.py", line 10, in raw_env
    version_num = parent_file[0].split("_")[-1].split(".")[0]
IndexError: list index out of range

I'm following everything in the documentation so not sure what I'm missing here.

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
ksivakumar
  • 481
  • 2
  • 5
  • 19

1 Answers1

1

It looks like a bug in the package's code. Given the pathname of /home/myname/miniconda3/envs/gym/lib/python3.8/site-packages/pettingzoo/atari/boxing/boxing.py

I'll comment the code inline based on what I see in the package's repository.

def raw_env(**kwargs):
    name = os.path.basename(__file__).split(".")[0] 
    # name = "/home/myname/miniconda3/envs/gym/lib/python3"

    parent_file = glob(
        os.path.join(os.path.dirname(os.path.dirname(__file__)), name + "*.py")
    )
    # parent_file = []

    version_num = parent_file[0].split("_")[-1].split(".")[0]
    # IndexError is raised because there is no element 0 in parent_file

    name = name + "_" + version_num
    return BaseAtariEnv(
        game="boxing", num_players=2, mode_num=None, env_name=name, **kwargs
    )

It looks like the package may have never been tested while installed on a path that has a '.' in it.

Rob Heiser
  • 2,792
  • 1
  • 21
  • 28
  • Ah that is really unfortunate. Is there any workaround for this? If I rename my python3.8 folder without the '.' would that create problems elsewhere or for other packages? – ksivakumar Aug 11 '22 at 20:26
  • You could try creating a soft link to the `python3.8` directory, that has a name with no dot in it, then use that path and see if it works correctly. That would at least confirm what I saw. I would definitely let the people on the project know, so they can fix it. If they're quick enough, you may not have to worry too much. – Rob Heiser Aug 11 '22 at 21:23
  • Actually, it looks like I was wrong about the behavior of `os.path.basename`. That gets the name of the directory that the given file is in. :| – Rob Heiser Aug 11 '22 at 21:29