简体   繁体   English

Ctypes:[WinError 126]无法找到DLL

[英]Ctypes: [WinError 126] Cant find DLL

I know there are a lot of threads about the WinError 126 and so on. 我知道关于WinError 126的线程很多,依此类推。 But I really need help... 但是我真的需要帮助...

I have a directory like this: 我有一个像这样的目录:

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

I have a 32 Bit and a 64 Bit Python Interpreter installed. 我安装了32位和64位Python解释器。 Now if I run mytestscript.py with a 32 Bit Interpreter, everything works fine. 现在,如果我使用32位解释器运行mytestscript.py,一切正常。

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

But if i run it with a 64 Bit Interpreter 但是如果我使用64位解释器运行它

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

I get the follwoing error: 我收到以下错误:

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

What could be the cause that the 64-Bit Python doesn't find the DLL? 64位Python找不到DLL的原因可能是什么? Do I have to add it to PATH / PYTHONPATH? 我是否必须将其添加到PATH / PYTHONPATH? Do I need some Microsoft Redistributable? 我需要一些Microsoft可再发行软件吗?

The DLL's are checked 64bit and 32bit and come from a vendor. 将检查DLL的64位和32位,并来自供应商。

This could also mean that another dependency is missing. 这也可能意味着缺少另一个依赖项。 Please use Dependencies (successor of Dependency Walker) to check what is happening behind the scenes. 请使用Dependencies (Dependency Walker的后继者)检查幕后发生的事情。

Maybe some runtime for 64-bit is missing. 也许缺少一些64位运行时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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