openai / gym

A toolkit for developing and comparing reinforcement learning algorithms.
https://www.gymlibrary.dev
Other
34.52k stars 8.6k forks source link

'module could not be found' when running gym.make for atari environment. #1726

Closed razzzu closed 4 years ago

razzzu commented 4 years ago

I solved this issue check the 3rd comment

when I run

gym.make('SpaceInvaders-v0')

I get the following TraceBack

OSError                                   Traceback (most recent call last)
<ipython-input-7-bd3516c22348> in <module>
----> 1 env = gym.make('SpaceInvaders-v0')

~\Anaconda3\lib\site-packages\gym\envs\registration.py in make(id, **kwargs)
    154 
    155 def make(id, **kwargs):
--> 156     return registry.make(id, **kwargs)
    157 
    158 def spec(id):

~\Anaconda3\lib\site-packages\gym\envs\registration.py in make(self, path, **kwargs)
     99             logger.info('Making new env: %s', path)
    100         spec = self.spec(path)
--> 101         env = spec.make(**kwargs)
    102         # We used to have people override _reset/_step rather than
    103         # reset/step. Set _gym_disable_underscore_compat = True on

~\Anaconda3\lib\site-packages\gym\envs\registration.py in make(self, **kwargs)
     70             env = self.entry_point(**_kwargs)
     71         else:
---> 72             cls = load(self.entry_point)
     73             env = cls(**_kwargs)
     74 

~\Anaconda3\lib\site-packages\gym\envs\registration.py in load(name)
     15 def load(name):
     16     mod_name, attr_name = name.split(":")
---> 17     mod = importlib.import_module(mod_name)
     18     fn = getattr(mod, attr_name)
     19     return fn

~\Anaconda3\lib\importlib\__init__.py in import_module(name, package)
    125                 break
    126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
    128 
    129 

~\Anaconda3\lib\importlib\_bootstrap.py in _gcd_import(name, package, level)

~\Anaconda3\lib\importlib\_bootstrap.py in _find_and_load(name, import_)

~\Anaconda3\lib\importlib\_bootstrap.py in _find_and_load_unlocked(name, import_)

~\Anaconda3\lib\importlib\_bootstrap.py in _load_unlocked(spec)

~\Anaconda3\lib\importlib\_bootstrap_external.py in exec_module(self, module)

~\Anaconda3\lib\importlib\_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

~\Anaconda3\lib\site-packages\gym\envs\atari\__init__.py in <module>
----> 1 from gym.envs.atari.atari_env import AtariEnv

~\Anaconda3\lib\site-packages\gym\envs\atari\atari_env.py in <module>
      7 
      8 try:
----> 9     import atari_py
     10 except ImportError as e:
     11     raise error.DependencyNotInstalled(

~\Anaconda3\lib\site-packages\atari_py\__init__.py in <module>
----> 1 from .ale_python_interface import *
      2 import os
      3 
      4 def _game_dir():
      5     return os.path.join(os.path.abspath(os.path.dirname(__file__)), "atari_roms")

~\Anaconda3\lib\site-packages\atari_py\ale_python_interface.py in <module>
     16 else:
     17     ale_lib = cdll.LoadLibrary(os.path.join(os.path.dirname(__file__),
---> 18                                             'ale_interface/ale_c.dll'))
     19 
     20 ale_lib.ALE_new.argtypes = None

~\Anaconda3\lib\ctypes\__init__.py in LoadLibrary(self, name)
    432 
    433     def LoadLibrary(self, name):
--> 434         return self._dlltype(name)
    435 
    436 cdll = LibraryLoader(CDLL)

~\Anaconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    354 
    355         if handle is None:
--> 356             self._handle = _dlopen(self._name, mode)
    357         else:
    358             self._handle = handle

OSError: [WinError 126] The specified module could not be found

I Think i am missing a dependency or some file but i cannot figure out which it is. I have 'cmake' and i have installed the gym[atari] dependency. I can run the CartPole enviorment without any issues but cannot run any atari environments.

Requirement already satisfied: gym[atari] in c:\users\swifty\anaconda3\lib\site-packages (0.15.3) Requirement already satisfied: pyglet<=1.3.2,>=1.2.0 in c:\users\swifty\anaconda3\lib\site-packages (from gym[atari]) (1.3.2) Requirement already satisfied: six in c:\users\swifty\anaconda3\lib\site-packages (from gym[atari]) (1.12.0) Requirement already satisfied: numpy>=1.10.4 in c:\users\swifty\anaconda3\lib\site-packages (from gym[atari]) (1.16.4) Requirement already satisfied: cloudpickle~=1.2.0 in c:\users\swifty\anaconda3\lib\site-packages (from gym[atari]) (1.2.1) Requirement already satisfied: scipy in c:\users\swifty\anaconda3\lib\site-packages (from gym[atari]) (1.2.1) Requirement already satisfied: opencv-python; extra == "atari" in c:\users\swifty\anaconda3\lib\site-packages (from gym[atari]) (4.1.1.26) Requirement already satisfied: atari-py~=0.2.0; extra == "atari" in c:\users\swifty\anaconda3\lib\site-packages (from gym[atari]) (0.2.6) Requirement already satisfied: Pillow; extra == "atari" in c:\users\swifty\anaconda3\lib\site-packages (from gym[atari]) (6.1.0) Requirement already satisfied: future in c:\users\swifty\anaconda3\lib\site-packages (from pyglet<=1.3.2,>=1.2.0->gym[atari]) (0.17.1)

P.S. This is my first time posting on github so i am sorry if i am doing something wrong.

christopherhesse commented 4 years ago

This looks like atari-py is somehow installed incorrectly. We don't officially support the windows binaries, but you can try uninstalling and reinstalling atari-py (make sure you're on windows 10).

If you can't run python -c 'import atari_py; print(atari_py.list_games())' then it's likely things are broken and you won't be able to make that environment.

Rong-Tao commented 4 years ago

same problem. The ale_c.dll file is missing. And I checked the folder, it is indeed missing in the folder. which is specified the import. could you please provide the dll file?

razzzu commented 4 years ago

I solved this problem.

  1. Uninstall gym and atari-py (If already installed): pip uninstall atari-py pip uninstall gym[atari]

  2. Download VS build tools here: https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16

  3. Run the VS build setup and select "C++ build tools" and install it. image

  4. Restart PC.

  5. Install cmake, atari-py and gym pip install cmake pip install atari-py pip install gym[atari]

  6. Now run the following code: import atari_py print(atari_py.list_games())

and if everything worked then it should return a list of all games as shown below

['adventure', 'air_raid', 'alien', 'amidar', 'assault', 'asterix', 'asteroids', 'atlantis', 'bank_heist', 'battle_zone', 'beam_rider', 'berzerk', 'bowling', 'boxing', 'breakout', 'carnival', 'centipede', 'chopper_command', 'crazy_climber', 'defender', 'demon_attack', 'double_dunk', 'elevator_action', 'enduro', 'fishing_derby', 'freeway', 'frostbite', 'gopher', 'gravitar', 'hero', 'ice_hockey', 'jamesbond', 'journey_escape', 'kaboom', 'kangaroo', 'krull', 'kung_fu_master', 'montezuma_revenge', 'ms_pacman', 'name_this_game', 'phoenix', 'pitfall', 'pong', 'pooyan', 'private_eye', 'qbert', 'riverraid', 'road_runner', 'robotank', 'seaquest', 'skiing', 'solaris', 'space_invaders', 'star_gunner', 'tennis', 'time_pilot', 'tutankham', 'up_n_down', 'venture', 'video_pinball', 'wizard_of_wor', 'yars_revenge', 'zaxxon']

JUZI1 commented 4 years ago

oooo you are so cool !!

bode135 commented 4 years ago

Thank u !!!! very cool!!!!!!!!!!!

chenranhuang commented 4 years ago

cool! Thank you very much!

delphinidae32 commented 4 years ago

it worked!! thank you so much :D

Arjunsekar commented 4 years ago

thank you

tylerhnothing commented 4 years ago

Dude thank you so much for posting the steps you took to fix this. This worked perfectly and I'm so excited to play with this.

MoeinR69 commented 4 years ago

thank you so much

weiguowilliam commented 4 years ago

thank u!

Ze1598 commented 4 years ago

Thanks @razzzu got it working by following your instructions

imdeep2905 commented 3 years ago

If anyone is facing issue like ...ale_c.dll' (or one of its dependencies). Try using the full path with constructor syntax. and can't fix with the steps described in the comment above, checkout this.

sparshgarg23 commented 3 years ago

imdeep 2905,thanks for the suggestion,I was facing the same issue. On a sidenote,it would be better if OpenAI could make sure their relase was stable and interoperable on all platforms.

XyuQian commented 3 years ago

thank u so much~ it works perfectly well!

hudsontek commented 3 years ago

If anyone is facing issue like ...ale_c.dll' (or one of its dependencies). Try using the full path with constructor syntax. and can't fix with the steps described in the comment above, checkout this.

After doing all steps mentioned by razzzu, the problem still exists. This worked for me! Thanks!

heartInsert commented 3 years ago

Thanks,bro.

Lifedecoder commented 3 years ago

cool, thanks!

RezaKakooee commented 3 years ago

so cool. works for me too. many thanks !

changfyg commented 3 years ago

It's an amazing solution by Razzzu. It works perfectly. What a saver. Many hugs and thank you very much 👍 💯

luiseia commented 3 years ago

万分感谢

KaiHong1015 commented 3 years ago

wtf bro it works for me haha, ty so much!!!

changfyg commented 3 years ago

Sorry my bad. My environment has some issues and looking into it. Thanks for your reply.


From: KaiHong1015 @.> Sent: Thursday, 13 May 2021 5:45 AM To: openai/gym @.> Cc: changfyg @.>; Comment @.> Subject: Re: [openai/gym] 'module could not be found' when running gym.make for atari environment. (#1726)

wtf bro it works for me haha, ty so much!!!

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/openai/gym/issues/1726#issuecomment-840049906, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AQJ7I35OMRPFEEJ77QLQYQLTNLLEBANCNFSM4JGM2UYQ.

Katherinaxxx commented 2 years ago

I solved the problem by conda install -c conda-forge atari_py