简体   繁体   中英

Error while trying to load .dll into Python “The specified module could not be found”

I've written ac code and compiled it into a dll, and now I'm trying to import it to Python, then I get the error "OSError: [WinError 126] The specified module could not be found".

I have already searched for solutions: in the code I use some other DLLs:

python36.dll
ioterasdk.dll
KERNEL32.dll

so I checked that all of them are included (except for KERNEL32.dll that I don't know how to check), and I also added "python36.dll"'s location to the System Environment Variables.

The code:

from ctypes import *
mydll = cdll.LoadLibrary("D:\\full\\path\\BlueTeraPy.dll")

I get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\admin\AppData\Local\Programs\Python\Python36-32\lib\ctypes\__init__.py", line 426, in LoadLibrary
    return self._dlltype(name)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python36-32\lib\ctypes\__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

I'm new to Stack Overflow and to DLLs in general, so if you need more information please tell. Thank you

You can't load the library itself, you must find the library in the dll.

import ctypes import *
from ctypes.util import *
dll = find_library("D:\\full\\path\\BlueTeraPy.dll")
lib = cdll.LoadLibrary(dll)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM