1
import os
import ctypes

os.path.dirname(os.path.abspath("Python_ESS_2-SWITCH.py"))
h = ctypes.WinDLL("ess_64.dll")

Both my OS and Python working directories are in the folder with the dll file I'm interested in.

The error that comes back is:

    347         ##
    348         if handle is None:
--> 349             self._handle = _dlopen(self._name, mode)
    350         else:
    351             self._handle = handle
OSError: [WinError 126] The specified module could not be found 

When I go into the ctypes module that the error traces back to I can see that the module that cannot be loaded is LoadLibrary:

if _os.name in ("nt", "ce"):
    print("in the if")
    from _ctypes import LoadLibrary as _dlopen

There's another thread that suggested some solutions but they have not yielded results for me. If anyone has any ideas I'd be very greatful.

lthermin
  • 183
  • 6
  • Execute your code and post the full stacktrace. Putting just pieces of code helps, but it's not enough.Also, this error doesn't mean that your *.dll* is not found. **It could either be it or one of the other *.dll*s (that it depends on - recursively) that can't be found**. You should check it using e.g. [Dependency Walker](http://www.dependencywalker.com) and see which one is the problem. Where is your *Python* script located (with respect to the *.dll*)? What is *ess\_64.dll* anyway? – CristiFati Nov 06 '18 at 16:06
  • Also: what does `os.getcwd()` return? – CristiFati Nov 06 '18 at 16:34
  • See [this answer](https://stackoverflow.com/a/18650202/235698) for a debugging method. – Mark Tolonen Nov 07 '18 at 07:47

0 Answers0