无法在python中加载c ++ DLL [英] could not load c++ DLL in python
问题描述
我试图在Python中使用C ++ .dll
,但是我甚至不能加载它。我正在尝试以下python代码来加载它:
I am trying to use a C++ .dll
in Python, but I can't even load it. I am trying the following python code to load it:
from ctypes import cdll
mydll = cdll.LoadLibrary('SORT_DLL.dll')
但是当我尝试运行这个时,我得到:
But when I try to run this I get:
D:\...\src\SORT_DLL\Debug>UseDll.py
Traceback (most recent call last):
File "D:\...\src\SORT_DLL\Debug\UseDll.py", line 2, in
<module>
mydll = cdll.LoadLibrary('SORT_DLL.dll')
File "C:\Python27\lib\ctypes\__init__.py", line 443, in LoadLibrary
return self._dlltype(name)
File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 ist keine zulõssige Win32-Anwendung
最后句子意思是%1不是一个有效的Win32应用程序的英文。
The last sentence means "%1 is not a valid Win32 application" in English.
我已经在 http://docs.python.org/2/library/ctypes.html#module-ctypes ,但这不是'
I already looked it up at http://docs.python.org/2/library/ctypes.html#module-ctypes , but this didn't lead to a solution for my problem.
推荐答案
听起来你有一个不兼容的Python版本,或者是使用设置错误DLL和Python解释器都必须是32位或64位。
Sounds like you have an incompatible version of Python installed or the DLL was compiled using the wrong settings. The DLL and the Python interpreter both have to be either 32 or 64 Bit.
这篇关于无法在python中加载c ++ DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!