Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WindowsError: [Error 126] The specified module could not be found

Tags:

python

ctypes

I am loading a dll in python using following code:

if os.path.exists(dll_path):      my_dll = ctypes.cdll.LoadLibrary(dll_path) 

But I am continuously getting the following error

WindowsError: [Error 126] The specified module could not be found

dll is present at the specified path, but I didn't understand why I'm getting the error.

like image 844
MA1 Avatar asked Dec 21 '09 14:12

MA1


1 Answers

Note that even if the DLL is in your path. If that DLL relies on other DLLs that are NOT in your path, you can get the same error. Windows could not find a dependency in this case. Windows is not real good at telling you what it could not find, only that it did not find something. It is up to you to figure that out. The Windows dll search path can be found here: http://msdn.microsoft.com/en-us/library/7d83bc18.aspx

In my case, being sure all needed dlls were in the same directory and doing a os.chdir() to that directory solved the problem.

like image 148
Doo Dah Avatar answered Sep 28 '22 03:09

Doo Dah