gpt4 book ai didi

python - Mac OS X Python ctypes cdll 错误 : image not found

转载 作者:太空宇宙 更新时间:2023-11-03 18:40:21 24 4
gpt4 key购买 nike

我是Python初学者。当我尝试加载外部 DLL(由其他人在 Windows 中编译)时,如下所示:

from ctypes import *
import cv2, cv as cv

PainterRender = CDLL('/Users/gulilin/Desktop/DLL/PainterRenderDll')

发生错误如下:

Traceback (most recent call last):
File "/Users/gulilin/Desktop/Project/DLL Test.py", line 7, in <module>
PainterRender = CDLL('/Users/gulilin/Desktop/DLL/PainterRenderDll')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Users/gulilin/Desktop/DLL/PainterRenderDll, 6): image not found

谁能告诉我这是怎么回事吗?

最佳答案

共享库(例如,Windows DLL)就像编译的二进制可执行文件:它们仅在编译它们的平台上运行。 ctypes 可以也不会在不同平台上的各种二进制格式和调用约定之间进行转换。您必须将 DLL 重新编译为 Mac OS 共享库(我认为是 .dylib)。

关于python - Mac OS X Python ctypes cdll 错误 : image not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20636036/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com