title: Python reading dll throws OSError: [WinError 126]
body: <p>I am clearly not the first one to have a problem to read a .dll file with python. Such example can be found there <a href="https://stackoverflow.com/questions/33365277/windowserror-error-126-when-loading-a-os-with-ctypes">WindowsError: [Error 126] when loading a OS with ctypes</a>, <a href="https://stackoverflow.com/questions/1940578/windowserror-error-126-the-specified-module-could-not-be-found">WindowsError: [Error 126] The specified module could not be found</a> or <a href="https://github.com/apache/incubator-mxnet/issues/6313" rel="nofollow noreferrer">https://github.com/apache/incubator-mxnet/issues/6313</a>.
  Knowing the extend of issues, I checked that the path to my dll is correct. I even did a small python script to minimally test it, adding as much as needed path I could think of:</p>
  
  <pre><code>import sys
  import os
  from ctypes import *
  
  if __name__ == '__main__':
      print(sys.path)
      sys.path.append(r"C:\Program Files (x86)\OpenBLAS\bin")
      pathWin = os.environ["PATH"]
      pathWin = pathWin.split(";")
      sys.path = sys.path + pathWin
      print(sys.path)
      dllToLoad = "F:/installMxnet/mxnet/build/Debug/libmxnet.dll"
      cdll.libmxnet = cdll.LoadLibrary(dllToLoad)
  </code></pre>
  
  <p>I still end up with this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.1\helpers\pydev\pydevd.py", line 1664, in &lt;module&gt;
      main()
    File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.1\helpers\pydev\pydevd.py", line 1658, in main
      globals = debugger.run(setup['file'], None, None, is_module)
    File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.1\helpers\pydev\pydevd.py", line 1068, in run
      pydev_imports.execfile(file, globals, locals)  # execute the script
    File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.1\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
      exec(compile(contents+"\n", file, 'exec'), glob, loc)
    File "main.py", line 16, in &lt;module&gt;
      cdll.libmxnet = cdll.LoadLibrary(dllToLoad)
    File "C:\Users\educrocq\AppData\Local\Programs\Python\Python36\lib\ctypes\__init__.py", line 426, in LoadLibrary
      return self._dlltype(name)
    File "C:\Users\educrocq\AppData\Local\Programs\Python\Python36\lib\ctypes\__init__.py", line 348, in __init__
      self._handle = _dlopen(self._name, mode)
  OSError: [WinError 126] The specified module could not be found
  </code></pre>
  
  <p>According to what I read, it could be because the dll has a dependency that can't be found. (And I guess that the dependency that would not find its dependency would raise the same problem, and so on...). It seems that the problem comes from Windows which is not verbose on its output message.</p>
  
  <p>But I need to know which dll can't be found in my situation, because this dll depends on lot of them... Is there a way to get which one is missing?</p>