c语言 - 尝试将.dll加载到 Python "The specified module could not be found" 时出错



我已经编写了一个c代码并将其编译为dll,现在我正在尝试将其导入Python,然后出现错误"OSError:[WinError 126]找不到指定的模块"。

我已经搜索了解决方案:在代码中我使用了其他一些DLL:

python36.dll
ioterasdk.dll
KERNEL32.dll

所以我检查了所有这些(除了我不知道如何检查的KERNEL32.dll(,并且我还在系统环境变量中添加了"python36.dll"的位置。

代码:

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

我收到此错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:UsersadminAppDataLocalProgramsPythonPython36-32libctypes__init__.py", line 426, in LoadLibrary
    return self._dlltype(name)
  File "C:UsersadminAppDataLocalProgramsPythonPython36-32libctypes__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

我是堆栈溢出和一般DLL的新手,所以如果您需要更多信息,请告诉。谢谢

您无法加载库本身,您必须在 dll 中找到库。

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

相关内容

最新更新