5

code:

import gym
env = gym.make('Breakout-v0')

I get an error:

Traceback (most recent call last):
File "C:/Users/danie/Downloads/Programming/Python/Programming/Pycharm/app.py", line 40, in 
gym.make("Breakout-v0")
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 156, in make
return registry.make(id, **kwargs)
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 101, in make
env = spec.make(**kwargs)
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 72, in make
cls = load(self.entry_point)
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 17, in load
mod = importlib.import_module(mod_name)
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\importlib_init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in find_and_load_unlocked
File "", line 677, in load_unlocked
File "", line 728, in exec_module
File "", line 219, in call_with_frames_removed
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\atari_init.py", line 1, in 
from gym.envs.atari.atari_env import AtariEnv
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\atari\atari_env.py", line 9, in 
import atari_py
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\atari_py_init.py", line 1, in 
from .ale_python_interface import *
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\atari_py\ale_python_interface.py", line 18, in 
'ale_interface/build/ale_c.dll'))
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\ctypes_init.py", line 434, in LoadLibrary
return self.dlltype(name)
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\ctypes_init.py", line 356, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
ilja
  • 2,592
  • 2
  • 16
  • 23
daniel
  • 73
  • 1
  • 6

4 Answers4

2

I was finally able to get around this problem with help from the following website: https://towardsdatascience.com/how-to-install-openai-gym-in-a-windows-environment-338969e24d30.

There were basically 3 things I had to do: 1) install Microsoft Visual C++ Build Tools, 2) install this specific verion of Atari https://github.com/Kojoley/atari-py.git, 3) Install Xming. Good luck to all Windows users :) This took me around 3 days to figure out.

Pieter
  • 36
  • 2
1

I have tried to make it work with python 3.8 and 3.9 on Windows 10. Installing Python 3.7 and using it as the Python Interpreter on PyCharm resolved the issue. I have searched for the missing file while having 3.8 + version of Python and it did not exist at all. Atari-py is supported only for Python 3.7 (https://github.com/openai/atari-py) so having a higher version of that would not work. It is a bad idea to download files from unlicensed places so I advise you to install the supported version of Python (3.5, 3.6, and 3.7). Even though gym can work on 3.9 the atari version will not. I did not need anything else installed (although I may have Microsoft Visual C++ Build Tools, but I deff did not need Xming), just import gym 0.18.0, pyglet 1.5.0, atari -py 0.2.6

0

Welcome to SO. If you trace the exception trace you see that a shared object loading function is called in ctypes' init.py file aliased as dlopen. On Windows, this correponds to WINAPI's LoadLibrary method. LoadLibrary is trying to load ale_c.dll. ALE is 'arcade learning environment'.

Search your computer for ale_c.dll or libale_c.dll

If you have ale_c.dll (most likely you are on Windows), refer to this answer to see how DLL's loaded with ctypes are basically LoadLibrary calls as I mentioned. It mentions all the stuff about DLL loading order etc. but, if you need a quick way around this, copy your dll under system32 folder.

Sıddık Açıl
  • 957
  • 8
  • 18
  • Hi Sıddık Açıl. Thank you for responding to me :) I found the file: 'ale_c.dll'. Sadly I wasn't able to find the file: 'libale_c.dll'. I hope that doesn't make too much change. What should I do next? – daniel Jun 25 '19 at 16:12
  • ok, I'm currently in my System32 folder, what '.dll' file is it? – daniel Jun 26 '19 at 14:19
  • Copy ale_c.dll to that folder. – Sıddık Açıl Jun 26 '19 at 14:31
  • Ok, I've done that so what am I supposed to do now? – daniel Jun 26 '19 at 14:46
  • Run your program again. – Sıddık Açıl Jun 26 '19 at 14:51
  • Well, add more details to the question then. So other people may help, too. What version of windows are you using and what are your steps to install openai-gym? – Sıddık Açıl Jun 26 '19 at 15:16
  • I'm using windows 10 and if I want to install gym I will just type: 'pip install gym' in command prompt. I'm using gym version: 0.13.0. – daniel Jun 26 '19 at 15:43
  • I deleted gym and reinstalled it on my Windows laptop. Your code ran flawlessly. But my ale_c.dll was in `ale_interface/ale_c.dll`, not in `ale_interface/build/ale_c.dll` . Go to your `ale_interface` folder`. Create a folder called `build` if it does not exists. Place ale_c.dll under this folder. You are good to go. – Sıddık Açıl Jun 26 '19 at 19:21
  • It's already in `ale_interface/build/ale_c.dll` I tried to delete the build folder because I got the same error and instead placed the `ale_c.dll` in the `ale_interface` folder by itself. I also got an error. – daniel Jun 27 '19 at 16:22
  • After you place the dll under ale_interface, you got the same error? – Sıddık Açıl Jun 27 '19 at 16:45
  • Yes, the absolutely same – daniel Jun 27 '19 at 17:39
  • Try [this](https://stackoverflow.com/questions/50516002/python-reading-dll-throws-oserror-winerror-126) answer. You have the dll everything seems fine but it is not loading. There seems to be a dependency missing in your computer which ale_c.dll uses. – Sıddık Açıl Jun 28 '19 at 00:39
  • Download depends.exe and run it. Then, open ale_c.dll through this program. It will show you what is missing. You most probably do not have MSVCP140D.dll or VCRUNTIME140D.dll. – Sıddık Açıl Jun 28 '19 at 00:52
  • Ok, I'll try that. It's nice that you're helping me. Thanks again :) – daniel Jun 28 '19 at 10:08
  • where can I download depends.exe? – daniel Jun 29 '19 at 09:42
  • Google "dependency walker". – Sıddık Açıl Jun 29 '19 at 11:52
  • My computer is saying: "The program you have selected cannot be associated with this file type. Please choose another program" – daniel Jul 06 '19 at 17:30
  • Open depends.exe then select file and click open. Then choose ale_c.dll from file browse dialog. – Sıddık Açıl Jul 06 '19 at 21:17
0

I had similar issue with Atari-Pacman. It is resolved by downloading atari_py-1.2.1-cp37-cp37m-win_amd64 which is for 64-bit Python 3.7, and installing it by using pip.