Ctypes找不到加载的d的dll依赖项

2024-10-05 14:21:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经将我的代码从C导出到我的导出.dll. 这个我的导出.dll反过来又取决于平台/qwindows.dll(夸脱)。与在同一目录中我的导出.dll在

以下是我使用ctypes的方式:

#myapp.py

from ctypes import *
mydll = WinDLL("myexported.dll")
mydll.independant_foo() #works fine
mydll.dependant_foo() #prompts the error and exits the program (python.exe)

运行脚本时:

^{pr2}$

在调用需要qwindows.dll. 此时它会提示:

This application failed to start because it could not find or load the Qt platform plugin "windows". Available platform plugins are: minimal, offscreen, windows. Reinstalling the application may fix this problem.

我尝试了以下方法,但没有一个奏效:

  • 将路径添加到qwindows.dll手动和使用操作系统环境[“路径”]
  • 在os.chdir公司(“路径/到/平台/qwindows.dll)或os.chdir公司(“路径/到/平台”)
  • 在os.path.append操作系统(“路径/到/平台/qwindows.dll)或os.path.append操作系统(“路径/到/平台”)
  • 复制qwindows.dll旁边我的导出.dll在

唯一有效的例子就是复制“平台”/qwindows.dll“旁边python.exe文件在我的python文件夹中。在

有10个其他类似的DLL无法找到,除非它们位于python.exe文件。在

我怎么能强迫python.exe以查看我的app.py目录?在


Tags: thepy路径目录fooapplicationoswindows