Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Getting an error trying to import environment OpenAI Gym

I am trying to run an OpenAI Gym environment:

env = gym.make("ALE/Breakout-v5", render_mode="rgb_array")

But I get the following error

Traceback (most recent call last):
  File "/Users/----/Documents/Spring 2023/----/----/yum.py", line 10, in <module>
    env = gym.make("ALE/Breakout-v5", render_mode="rgb_array")
  File "/Users/----/anaconda3/envs/----/lib/python3.10/site-packages/gymnasium/envs/registration.py", line 592, in make
    _check_version_exists(ns, name, version)
  File "/Users/----/anaconda3/envs/----/lib/python3.10/site-packages/gymnasium/envs/registration.py", line 218, in _check_version_exists
    _check_name_exists(ns, name)
  File "/Users/----/anaconda3/envs/----/lib/python3.10/site-packages/gymnasium/envs/registration.py", line 185, in _check_name_exists
    _check_namespace_exists(ns)
  File "/Users/----/anaconda3/envs/----/lib/python3.10/site-packages/gymnasium/envs/registration.py", line 180, in _check_namespace_exists
    raise error.NamespaceNotFound(f"Namespace {ns} not found. {suggestion_msg}")
gymnasium.error.NamespaceNotFound: Namespace ALE not found. Have you installed the proper package for ALE?

I’ve looked at all the similar errors that people have discussed online, but I cannot find any fixes that work for me.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Installing the gym as below worked in my environment. (Python 3.7)

pip install "gym[atari, accept-rom-license]"

if you are using gymnasium:

pip install "gymnasium[atari, accept-rom-license]"
import gym # or "import gymnasium as gym"

if __name__ == '__main__':
    env = gym.make("ALE/Breakout-v5")
A.L.E: Arcade Learning Environment (version 0.8.1+53f58b7)
[Powered by Stella]

If it still doesn’t work try adding the following import

import ale_py
# if using gymnasium
import shimmy

import gym # or "import gymnasium as gym"

Remember to create a new empty environment before installation.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading