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.
When I see things like this – it is usually because there are backslashes in the path which get converted.
For example – the following will fail – because \t in the string is converted to TAB character.
There are 3 solutions (if that is the problem)
a) Use double slashes…
b) use forward slashes
c) use RAW strings (prefacing the string with r
While this third one works – I have gotten the impression from time to time that it is not considered ‘correct’ because RAW strings were meant for regular expressions. I have been using it for paths on Windows in Python for years without problem 🙂 )