4

I am currently trying to use the Atari module for gym/openai. I have successfully managed to install the dependency.

Patricks-MacBook-Pro:~ patrickmaynard$ python3.6 -m pip install gym[atari]
Requirement already satisfied: gym[atari] in /usr/local/lib/python3.6/site-packages (0.10.5)
Requirement already satisfied: six in /usr/local/lib/python3.6/site-packages (from gym[atari]) (1.11.0)
Requirement already satisfied: pyglet>=1.2.0 in /usr/local/lib/python3.6/site-packages (from gym[atari]) (1.3.2)
Requirement already satisfied: requests>=2.0 in /usr/local/lib/python3.6/site-packages (from gym[atari]) (2.18.4)
Requirement already satisfied: numpy>=1.10.4 in /usr/local/lib/python3.6/site-packages (from gym[atari]) (1.14.3)
Requirement already satisfied: Pillow; extra == "atari" in /usr/local/lib/python3.6/site-packages (from gym[atari]) (5.1.0)
Requirement already satisfied: PyOpenGL; extra == "atari" in /usr/local/lib/python3.6/site-packages (from gym[atari]) (3.1.0)
Requirement already satisfied: atari-py>=0.1.1; extra == "atari" in /usr/local/lib/python3.6/site-packages (from gym[atari]) (0.1.1)
Requirement already satisfied: future in /usr/local/lib/python3.6/site-packages (from pyglet>=1.2.0->gym[atari]) (0.16.0)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/site-packages (from requests>=2.0->gym[atari]) (2018.4.16)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/local/lib/python3.6/site-packages (from requests>=2.0->gym[atari]) (1.22)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/site-packages (from requests>=2.0->gym[atari]) (3.0.4)
Requirement already satisfied: idna<2.7,>=2.5 in /usr/local/lib/python3.6/site-packages (from requests>=2.0->gym[atari]) (2.6)

However, when I try to run the file the compiler cannot find the module and I get the following error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gym/envs/atari/atari_env.py", line 9, in <module>
    import atari_py
ModuleNotFoundError: No module named 'atari_py'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/patrickmaynard/TicTacToe/recipe-578816-1.py", line 170, in <module>
    env = gym.make('Pong-v0')
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gym/envs/registration.py", line 167, in make
    return registry.make(id)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gym/envs/registration.py", line 119, in make
    env = spec.make()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gym/envs/registration.py", line 85, in make
    cls = load(self._entry_point)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gym/envs/registration.py", line 14, in load
    result = entry_point.load(False)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2291, in load
    return self.resolve()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gym/envs/atari/__init__.py", line 1, in <module>
    from gym.envs.atari.atari_env import AtariEnv
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gym/envs/atari/atari_env.py", line 11, in <module>
    raise error.DependencyNotInstalled("{}. (HINT: you can install Atari dependencies by running 'pip install gym[atari]'.)".format(e))
gym.error.DependencyNotInstalled: No module named 'atari_py'. (HINT: you can install Atari dependencies by running 'pip install gym[atari]'.)

gym and cmake have already been installed.

Marcus Campbell
  • 2,746
  • 4
  • 22
  • 36
Patrick Maynard
  • 314
  • 3
  • 18

3 Answers3

5

I think maybe you install atair in pip, you can try to use pip3 install. The importlib in python2 seems not compatible.

pip3 install atari-py

it works for me :)

Bingbing
  • 51
  • 3
0

Check the version of atari_py in PyCharm IDE because some of the versions have been depicted so they are no longer working or are missing a file (ale_c.dll) I had issues when installing atari_py and gym with Python as I had to choose the correct version of everything so it works. The highest version of Python atari_py will run on is 3.7 (Python 3.7) and as far as atari_py goes I am using 0.2.6 for it as I could not get anything to work on the higher version. Gym imports atari_py (atari-py) but as I said before it has been depicted so the newest version of Gym 0.21.0 (0.20.0 and higher) use ale-py which works a little differently as it suggests you do not do env.render() and games are v5 (everything below v5 is from atari_py). Sadly I could not get Gym 0.21.0 and ale-py to work correctly on a single game as the only example I found of a game was :

import gym

env = gym.make('ALE/Breakout-v5',
    obs_type='rgb',                   # ram | rgb | grayscale
    frameskip=5,                     # frame skip
    mode=0,                           # game mode, see Machado et al. 2018
    difficulty=0,                     # game difficulty, see Machado et al. 2018
    repeat_action_probability=0.25,   # Sticky action probability
    full_action_space=True,           # Use all actions
    render_mode=None                  # None | human | rgb_array
)
  • from https://brosa.ca/blog/ale-release-v0.7 and the game does not work correctly. (meaning on rendering the game the ball is not there and nothing happens - saw the same issue for lower version of the game where nothing happens.) enter image description here
-1

'atari_py' will not work in my pycharm IDE. Try another IDE or run the file in terminal/command line.

Patrick Maynard
  • 314
  • 3
  • 18