为什么python在使用ctypes加载dll时会引发错误OSError?

时间:2018-05-07 09:35:47

标签: python

我需要在项目期间将.dll与python连接起来。 我在macOS High Sierra Version 10.13.4上运行python并使用Python 3.6.0 64bits。 这是我的代码:

import ctypes
zelib = ctypes.CDLL("as5216x64.dll")

这引起了我的错误:

Traceback (most recent call last):

File "<ipython-input-36-d20b19e4224c>", line 1, in <module>
Clib = ffi.dlopen("as5216x64.dll")

File "/Users/Thomas/anaconda/lib/python3.6/site-packages/cffi/api.py", line 139, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)

File "/Users/Thomas/anaconda/lib/python3.6/site-packages/cffi/api.py", line 769, in _make_ffi_library
backendlib = _load_backend_lib(backend, libname, flags)

File "/Users/Thomas/anaconda/lib/python3.6/site-packages/cffi/api.py", line 758, in _load_backend_lib
return backend.load_library(name, flags)

OSError: cannot load library as5216x64.dll: dlopen(as5216x64.dll, 2): no suitable image found.  Did find:
as5216x64.dll: unknown file type, first eight bytes: 0x4D 0x5A 0x90 0x00 0x03 0x00 0x00 0x00
/Users/Thomas/CALAIDOSCOPE/as5216x64.dll: unknown file type, first eight bytes: 0x4D 0x5A 0x90 0x00 0x03 0x00 0x00 0x00

我也尝试使用cffi,但它引发了同样的错误。 {i}尝试使用.dll来连接我真正需要使用的硬件。

0 个答案:

没有答案