在python中加载DLL错误,而不是有效的win32应用程序 [英] Error loading DLL in python, not a valid win32 application

查看:3526
本文介绍了在python中加载DLL错误,而不是有效的win32应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在python中加载一个DLL来调用函数。

I am trying to load a DLL in python to call functions.

import ctypes
from ctypes import *

dsusb = ctypes.WinDLL('c:\python27\dsusb.dll')

我的堆栈中出现以下错误。 / p>

I get the following error in my stack.

C:\Python27>python test.py
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    dsusb = ctypes.WinDLL('c:\python27\dsusb.dll')
  File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application

我也尝试使用相同代码的cdll。

I also tried cdll with the same code.

我查看错误,Windows表示这是由于一个包含空格的路径...我不认为是真的问题...

I looked up the error and windows says it's due to a path containing spaces... which I do not think is really the problem...

我加载这个DLL错了,或者有什么可能在dll?

Am I loading this DLL wrong or is there something that might be wrong in the dll?

推荐答案

正如意见所示,它可能是一个架构问题。

As the comments suggest, it could be an architecture problem.

如果您使用的是64位Python的32位DLL,反之亦然,那么您可能会收到错误。

If you're using a 32bit DLL with 64bit Python, or vice-versa, then you'll probably get errors.

由于我已经拥有之前,我建议尝试使用32位Python加载您的DLL。

Since I've had your error before, I recommend trying to load your DLL with 32bit Python.

这篇关于在python中加载DLL错误,而不是有效的win32应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆