gym icon indicating copy to clipboard operation
gym copied to clipboard

ALE Namespace does not exist.

Open Nervoload opened this issue 3 years ago • 17 comments

I am attempting to access the Atari environments, and upon importing the latest versions of ale-py, autorom, gym, gymnasium even, I get the following error when attempting to make and environment of any space under the ALE namespace:

env = gym.make(ALE/Breakout-v5)


NamespaceNotFound Traceback (most recent call last) in 1 env_name = 'ALE/Breakout-v5' ----> 2 env = gym.make(env_name)

4 frames /usr/local/lib/python3.9/dist-packages/gym/envs/registration.py in _assert_namespace_exists(self, namespace) 266 else: 267 message += f" Have you installed the proper package for {namespace}?" --> 268 raise error.NamespaceNotFound(message) 269 270 def _assert_name_exists(self, namespace: Optional[str], name: str) -> None:

NamespaceNotFound: Namespace ALE does not exist. Have you installed the proper package for ALE?

Yes, I did in fact download namespace ALE.

This may be a notebook exclusive error, but it did happen on my personal base python3.10. Somehow, after reinstalling and changing a bunch of packages, I actually got it to work on my personal computer.

I suspect that gym.make pulls from existing files under gym/envs, and somehow the ALE package does not reroute the directory when attaching the namespace to it. I will play with this to try to figure out the solution by added the ALE roms to the gym/envs folder, or by changing the namespaces directly.

gym version: 0.28.1

System Info Describe the characteristic of your environment: ipynb, notebook =

  • Describe how Gym was installed (pip, docker, source, ...) latest version of pip, google colab AND MacOS latest M1 (but it ended up working there)

Nervoload avatar Mar 28 '23 19:03 Nervoload

Have you run pip install "gym[accept-rom-license, atari]"? Could you print gym.envs.registration.registry.keys()?

pseudo-rnd-thoughts avatar Mar 28 '23 21:03 pseudo-rnd-thoughts

I have similar problem when making an environment through gym.make("ALE/Riverraid-v5"). I run both commands you suggested and the return for the print was: dict_keys(['CartPole-v0', 'CartPole-v1', 'MountainCar-v0', 'MountainCarContinuous-v0', 'Pendulum-v1', 'Acrobot-v1', 'CartPoleJax-v0', 'CartPoleJax-v1', 'PendulumJax-v0', 'LunarLander-v2', 'LunarLanderContinuous-v2', 'BipedalWalker-v3', 'BipedalWalkerHardcore-v3', 'CarRacing-v2', 'Blackjack-v1', 'FrozenLake-v1', 'FrozenLake8x8-v1', 'CliffWalking-v0', 'Taxi-v3', 'Jax-Blackjack-v0', 'Reacher-v2', 'Reacher-v4', 'Pusher-v2', 'Pusher-v4', 'InvertedPendulum-v2', 'InvertedPendulum-v4', 'InvertedDoublePendulum-v2', 'InvertedDoublePendulum-v4', 'HalfCheetah-v2', 'HalfCheetah-v3', 'HalfCheetah-v4', 'Hopper-v2', 'Hopper-v3', 'Hopper-v4', 'Swimmer-v2', 'Swimmer-v3', 'Swimmer-v4', 'Walker2d-v2', 'Walker2d-v3', 'Walker2d-v4', 'Ant-v2', 'Ant-v3', 'Ant-v4', 'Humanoid-v2', 'Humanoid-v3', 'Humanoid-v4', 'HumanoidStandup-v2', 'HumanoidStandup-v4', 'GymV21Environment-v0', 'GymV26Environment-v0'])

rezkanas avatar Apr 01 '23 15:04 rezkanas

@rezkanas You are using gymnasium not gym, and has an additional requirement, please run pip install gymnasium[atari, accept-rom-licesnse]

pseudo-rnd-thoughts avatar Apr 01 '23 16:04 pseudo-rnd-thoughts

I'm also having a similar problem, but installing the gymnasium code above was not working for me. The error is pretty much exactly the same as the one from the original post, and I have the same keys as the person above as well. Is there any way you could help me?

OwenFa avatar Apr 11 '23 20:04 OwenFa

Hey @pseudo-rnd-thoughts, I am having the same issue as @rezkanas, with the same keys, even after running the code you suggested. Can you please let us know what to do in this case?

Elemento24 avatar Apr 12 '23 13:04 Elemento24

If you are using gym then you need to run pip install "gym[atari, accept-rom-license]" and if you are using gymnasium you need to run pip install "gymnasium[atari, accept-rom-license]".

If you have run the appropriate command then do

import gym # or "import gymnasium as gym"
print(gym.make("ALE/Pong-v5"))

and it doesn't work then run

import ale_py
# if using gymnasium
import shimmy

import gym # or "import gymnasium as gym"
print(gym.envs.registry.keys())

pseudo-rnd-thoughts avatar Apr 12 '23 14:04 pseudo-rnd-thoughts

Just did the accept rom license for gymnasium, and still did not work. Here is the output for the keys: dict_keys(['CartPole-v0', 'CartPole-v1', 'MountainCar-v0', 'MountainCarContinuous-v0', 'Pendulum-v1', 'Acrobot-v1', 'LunarLander-v2', 'LunarLanderContinuous-v2', 'BipedalWalker-v3', 'BipedalWalkerHardcore-v3', 'CarRacing-v2', 'Blackjack-v1', 'FrozenLake-v1', 'FrozenLake8x8-v1', 'CliffWalking-v0', 'Taxi-v3', 'Reacher-v2', 'Reacher-v4', 'Pusher-v2', 'Pusher-v4', 'InvertedPendulum-v2', 'InvertedPendulum-v4', 'InvertedDoublePendulum-v2', 'InvertedDoublePendulum-v4', 'HalfCheetah-v2', 'HalfCheetah-v3', 'HalfCheetah-v4', 'Hopper-v2', 'Hopper-v3', 'Hopper-v4', 'Swimmer-v2', 'Swimmer-v3', 'Swimmer-v4', 'Walker2d-v2', 'Walker2d-v3', 'Walker2d-v4', 'Ant-v2', 'Ant-v3', 'Ant-v4', 'Humanoid-v2', 'Humanoid-v3', 'Humanoid-v4', 'HumanoidStandup-v2', 'HumanoidStandup-v4', 'GymV26Environment-v0'])

OwenFa avatar Apr 12 '23 16:04 OwenFa

Hey @pseudo-rnd-thoughts, Thanks a lot, you are a real saviour 🥳 Hey @OwenFa, try using what Mark has suggested above, it worked in my environment (gymnasium with version 0.28.1). I really hope that it works in yours as well 😄

Elemento24 avatar Apr 12 '23 16:04 Elemento24

@OwenFa Did you do the import ale_py and import shimmy did these work? Are you using gymnasium from pip or a git cloned version locally?

pseudo-rnd-thoughts avatar Apr 13 '23 09:04 pseudo-rnd-thoughts

The solutions Mark suggested didn't work for Python 3.8. But I created a new environment with 3.7 and installed "gym[accept-rom-license, atari]" and Breakout now works fine.

haeren avatar Apr 20 '23 07:04 haeren

I get the same error with gymnasium but not gym. To give a little bit of context, it's a distributed script where submitit is used to spawn jobs on multiple nodes that all create their own copies of a gym env and send data to the main node asynchronously. If I create a "ALE/Pong-v5" on the main node it works, but spawn processes cannot. With gym it's working fine. To reproduce: on https://github.com/pytorch/rl/pull/1672, execute rl/examples/distributed/collectors/multi_nodes/delayed_dist.py. Replacing the backend in that script with gymnasium leads to the error reported in this issue on the distant nodes.

vmoens avatar Nov 03 '23 14:11 vmoens

I know this issue is basically closed but if you are using gym in a jupyter notebook test it in a normal python file. My environment loaded in everything correctly in normal python.

Charles-Gormley avatar Dec 02 '23 08:12 Charles-Gormley

If someone is still having issues with gymnasium, i just deactivated and activated my virtual environment(venv) again and it fixed things for me. If you are using jupyter notebook in vscode, switching to different kernel server and then going back to original kernel server again fixed the issue.

gurpreetsinghmukker avatar Dec 13 '23 22:12 gurpreetsinghmukker

Thanks, I did all of the above but it was still showing the same error. I restarted the colab notebook (with the above fixes) and it worked!

kushagra-m avatar Apr 06 '24 14:04 kushagra-m