Question regarding python/ctypes and dll loading.
I have created a C Dll (extern C declarations) using VSExpress 2010. I can load and execute this dll with a CPP test program. However, when I attempt to load the dll in python via ctypes, I get the old "WindowsError: [Errno 126] The specified module could not be found" error message.
So far I have done the following:
1.) Triple checked the path to the DLL on the python side and tried an absolute path to be completely sure the DLL is being found.
2.) Brought up the DLL in depends.exe and verified nothing seems to be missing in the dependency tree (on Win 7 so the depends output is a little flaky, but from research nothing seems out of place, anyone know of a depends-like tool that is more Win7 compatible?)
3.) I have a .bat file that sets all my environment variables and have taken other actions as well (co-locating dependencies) to make sure all dependencies are resolved. Again, everything in depends is showing clean except the typical Win7 OS failures.
Anyone know a good way to debug this type of problem? A better version of depends? A way to see exactly what symbol/module failed to load from python?
Again, the CPP test program loads and execute the dll perfectly. Really not sure what is happening on the Python side. Any help in debugging is appreciated.
Thanks.
Use Sysinternals Process Monitor. Configure it to monitor the
python.exe
process forCreateFile
operations:Then run your script. In the example below, I ran:
x.dll
does not exist, with the following result near the bottom of the trace, but note that any missing dependent DLL would show up similarly: