PacktPublishing / Hands-On-Intelligent-Agents-with-OpenAI-Gym

Code for Hands On Intelligent Agents with OpenAI Gym book to get started and learn to build deep reinforcement learning agents using PyTorch
https://www.packtpub.com/big-data-and-business-intelligence/hands-intelligent-agents-openai-gym
MIT License
366 stars 149 forks source link

ModuleNotFoundError: No module named 'gym.envs.atari' still happening #39

Closed profversaggi closed 2 years ago

profversaggi commented 2 years ago

I've seen this issue closed already but I tried the proposed solutions and am getting the same errors:

(base) profversaggi@ubuntu-nuc:~/OpenAIGym/gym$ python run_gym_env.py Alien-ram-v4 2000 /home/profversaggi/OpenAIGym/openai-gym/lib/python3.9/site-packages/ale_py/roms/init.py:94: DeprecationWarning: Automatic importing of atari-py roms won't be supported in future releases of ale-py. Please migrate over to using ale-import-roms OR an ALE-supported ROM package. To make this warning disappear you can run ale-import-roms --import-from-pkg atari_py.atari_roms.For more information see: https://github.com/mgbellemare/Arcade-Learning-Environment#rom-management _RESOLVED_ROMS = _resolve_roms() /home/profversaggi/OpenAIGym/gym/gym/envs/registration.py:505: UserWarning: WARN: The environment Alien-ram-v4 is out of date. You should consider upgrading to version v5 with the environment ID ALE/Alien-ram-v5. logger.warn( Traceback (most recent call last): File "/home/profversaggi/OpenAIGym/gym/run_gym_env.py", line 17, in run_gym_env(sys.argv) File "/home/profversaggi/OpenAIGym/gym/run_gym_env.py", line 9, in run_gym_env env = gym.make(argv[1]) # Name of the environment supplied as 1st argument File "/home/profversaggi/OpenAIGym/gym/gym/envs/registration.py", line 676, in make return registry.make(id, kwargs) File "/home/profversaggi/OpenAIGym/gym/gym/envs/registration.py", line 520, in make return spec.make(kwargs) File "/home/profversaggi/OpenAIGym/gym/gym/envs/registration.py", line 139, in make cls = load(self.entry_point) File "/home/profversaggi/OpenAIGym/gym/gym/envs/registration.py", line 55, in load mod = importlib.import_module(mod_name) File "/home/profversaggi/anaconda3/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 984, in _find_and_load_unlocked

ModuleNotFoundError: No module named 'gym.envs.atari'

(base) profversaggi@ubuntu-nuc:~/OpenAIGym/gym$ pip list Package Version


ale-py 0.7.4 atari-py 0.2.6 Box2D 2.3.10 box2d-py 2.3.5 certifi 2021.10.8 cffi 1.15.0 charset-normalizer 2.0.12 cloudpickle 1.6.0 Cython 0.29.28 future 0.18.2 glfw 2.5.1 gym 0.23.1 gym-notices 0.0.6 idna 3.3 imageio 2.16.1 importlib-metadata 4.11.3 importlib-resources 5.6.0 lockfile 0.12.2 lz4 4.0.0 mujoco-py 1.50.1.68 numpy 1.22.3 opencv-python 4.5.5.64 Pillow 9.0.1 pip 22.0.4 pycparser 2.21 pygame 2.1.0 pyglet 1.5.0 requests 2.27.1 scipy 1.8.0 setuptools 61.0.0 six 1.16.0 torch 1.11.0 torchvision 0.12.0 typing_extensions 4.1.1 urllib3 1.26.9 wheel 0.37.1 zipp 3.7.0

It might be helpful to note that I'm using python virtual environments.

praveen-palanisamy commented 2 years ago

Hi @profversaggi , thank you for the detailed post. I see that you already are following the issue and tried the resolutions proposed in the issue page on the OpenAI Gym library repo. This issue seems to be with the OpenAI Gym code in the version you are using as per your pip list output. Here are the two options you can try to resolve the issue:

  1. Setup your python virtual environment using this conda environment definition and then continue with your experiments with the book. E.g. running: python run_gym_env.py Alien-ram-v4 2000
  2. If you want to use the latest OpenAI Gym version (0.23.1) with ale-py 0.7.4 please use v5 of the Alien-ram env using the environment ID: ALE/Alien-ram-v5 instead of Alien-ram-v4.

I hope that helps you.