【问题标题】:Ctypes: [WinError 126] Cant find DLLCtypes:[WinError 126] 找不到 DLL
【发布时间】:2019-05-15 12:41:44
【问题描述】:

我知道有很多关于 WinError 126 等的帖子。但我真的需要帮助...

我有一个这样的目录:

  • mytestscript.py
  • my32bit.dll
  • my64bit.dll

我安装了 32 位和 64 位 Python 解释器。 现在,如果我使用 32 位解释器运行 mytestscript.py,一切正常。

import ctypes
dll = ctypes.windll.LoadLibrary("my32bit.dll")
print(dll)

但如果我使用 64 位解释器运行它

import ctypes
dll = ctypes.windll.LoadLibrary("my64bit.dll")
print(dll)

我得到以下错误:

Traceback (most recent call last):
  File "C:/Users/Heinzeri/Desktop/TEMPY/mytestscript.py", line 4, in <module>
    dll = ctypes.windll.LoadLibrary("my64bit.dll")
  File "C:\Program Files\Python37-64\Lib\ctypes\__init__.py", line 434, in LoadLibrary
    return self._dlltype(name)
  File "C:\Program Files\Python37-64\Lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [Error 126] The specified module could not be found

64 位 Python 找不到 DLL 的原因可能是什么? 我必须将它添加到 PATH / PYTHONPATH 吗? 我需要一些 Microsoft Redistributable 吗?

DLL 经过 64 位和 32 位检查,并且来自供应商。

【问题讨论】:

    标签: python ctypes 32bit-64bit


    【解决方案1】:

    这也可能意味着缺少另一个依赖项。请使用Dependencies(Dependency Walker 的继任者)来检查幕后发生的事情。

    可能缺少一些 64 位的运行时。

    【讨论】:

    • 感谢您的提示。是的,MSVCP110.dll 丢失了。所以我建议的解决方案也是正确的,但我有错误的 Microsoft 可分发版本。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-24
    • 2021-11-23
    • 2020-08-19
    相关资源
    最近更新 更多