I am trying to load a DLL from Python, but get WindowsError: [Error 126] The specified module could not be found.
import ctypes
my_dll = "C:/smt/toolbox/dlls/NMSim_Libraries.dll"
nmsim = ctypes.cdll.LoadLibrary(my_dll)
When I used Dependency Walker, it states that 3 dependencies are missing, all of which are in the path: "C:\Users\skeyel\AppData\Local\Continuum\Anaconda2\Lib\site-packages\numpy\core"
I tried adding this path to the system path using:
import sys
sys.path.append("C:\\Users\\skeyel\\AppData\\Local\\Continuum\\Anaconda2\\Lib\\site-packages\\numpy\\core\\")
but this did not solve the problem. How do I get the .dll to communicate with the dependencies?
NOTES:
There are two Python installations on my computer: 2.7.8 that shipped with ArcGIS and 2.7.11 that shipped with Anaconda. It runs fine when run through the Spyder IDE that came with the Anaconda installation.
It runs fine on my laptop (on both 2.7.8 and 2.7.11).
I've checked and/or tried a variety of things based on the advice from: WindowsError: [Error 126] The specified module could not be found
3a. The dll exists and the path to the dll is correct, as it works for one version when I copy and paste the exact same code
3b. the DLL and Python are both set up for 32 bits (note: the OS is 64 bit). Using
import platform
followed byplatform.architecture()
gives both versions as 32-bit.3c. I have tried adjusting
sys.path
to include the same paths between the two installations3d. I have tried
os.chdir()
to change to the .dll directory, and then just loading the dll by name with no path information3e. I have tried copying and pasting the listed missing dependencies into the same folder as the .dll
I tried copying, pasting and running the (minimally modified) code from selected answer here: Python | accessing dll using ctypes
Here is the full traceback:
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\skeyel\AppData\Local\Continuum\Anaconda2\Lib\ctypes\__init__.py", line 443, in LoadLibrary
return self._dlltype(name)
File "C:\Users\skeyel\AppData\Local\Continuum\Anaconda2\Lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found
It seems like there is something simple that I'm missing - anyone know what it is?
Many thanks.