如何修复“导入 QtWidgets 时 DLL 加载失败”?

ALI3N W0R1D

问题:

因此,编译后,在 dist 文件夹中,有“PyQt5.Qt.pyd”文件,但出现此错误:

Traceback (most recent call last):
  File "main.py", line 102, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "<loader>", line 10, in <module>
  File "<loader>", line 8, in __load
ImportError: (DLL load failed while importing QtWidgets: The specified module could not be found.) 'Z:\\Project\\dist\\PyQt5.QtWidgets.pyd'

我很确定这个“Qt”文件夹来自"C:\Program Files (x86)\Python38-32\Lib\site-packages\PyQt5\Qt",编译后被转换为"PyQt5.Qt.pyd"文件我猜是造成这个错误的原因。因为当我将此位置添加到我的 Windows PATH: "C:\Program Files (x86)\Python38-32\Lib\site-packages\PyQt5\Qt\bin" 时,编译后的程序可以完美运行。


我的临时修复是:

我将“Qt”文件夹复制到“dist”,并制作了一个批处理脚本,将“.\dist\Qt\bin”添加到PATH,对于当前的CMD窗口......这样我就可以将它发送给我的客户端暂时测试一下……但这远不是最终的解决方案……该怎么办?

(我也尝试将“bin”或“platform\qwindows.dll”从“Qt”复制到dist,但没有运气......)

我将不胜感激任何有关这方面的帮助或建议。提前致谢!


我的信息:

操作系统信息: Windows 10 x64,Python 3.8.6 x32

点冻结:

altgraph==0.17
cachetools==4.1.1
fbs==0.9.0
future==0.18.2
macholib==1.14
pefile==2019.4.18
Pillow==8.0.1
 py2exe==0.10.0.2
PyInstaller==3.4
 PyQt5==5.15.1
PyQt5-sip==12.8.1
pywin32==228
pywin32-ctypes==0.2.0
six==1.15.0

py2exe setup.py:

from distutils.core import setup
import py2exe
setup(windows=[{"script":"main.py"}], options={"py2exe":{"includes":["PyQt5.Qt","PyQt5.sip","PyQt5.QtWidgets","PyQt5.QtCore", "PyQt5.QtGui"]}})
苏斯·厄诺

将所有 dll 从 PyQt5\Qt\bin 复制到 dist,除了以 Qt5* 开头的那些(如果您不使用 direct3d 或 opengl,您可能不需要 d3dcompiler_47、libEGL、libGLESv2 和 opengl32sw)

我建议您尝试在新安装的 Windows(可能在虚拟机中)上运行使用 py2exe 转换的应用程序,以查看它是否有其他依赖项。

更新:实际上,我只需要为 Visual Studio 2015、2017 和 2019 安装 Microsoft Visual C++ Redistributable,无需复制任何 dll 文件。https://support.microsoft.com/en-us/topic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何修复“导入错误:DLL 加载失败:找不到指定的过程”。在导入 tensorflow-gpu 时?

如何在导入win32api时修复“ ImportError:DLL加载失败”

“导入错误:导入_openmp_helpers时DLL加载失败”?

使用PyInstaller时出现“ ImportError:导入时DLL加载失败”

导入PyQt5时DLL加载失败

导入cv2时DLL加载失败错误

导入具有GPU支持的TensorFlow时DLL加载失败

导入cv2(opencv)时出现“ DLL加载失败”

DLL加载失败:导入scipy时找不到指定的模块

导入张量流时出现“ ImportError:DLL加载失败”

cx_Freeze ImportError:导入_ctypes时,DLL加载失败失败:找不到指定的模块

导入PySide2时,DLL加载失败,仅在调试时

如何解决:“ ImportError:DLL加载失败,找不到指定的过程。” DLL在那里时

导入错误:DLL 加载失败:找不到指定的模块。在尝试导入 TensorFlow 时

发生异常:导入pdftotext时,ImportError DLL加载失败:找不到指定的模块

ImportError:导入_psycopg时DLL加载失败:找不到指定的模块

使用conda从Anaconda导入numpy时出错(DLL加载失败:找不到指定的模块)

从 sklearn 导入“kfold”时出现“DLL 加载失败:找不到指定的模块”错误

ImportError:导入pyexpat时DLL加载失败:找不到指定的模块

尝试导入sklearn模块时出错:ImportError:DLL加载失败:找不到指定的模块

导入错误:DLL加载失败:使用cxfreeze时找不到指定的模块

Pyinstaller ImportError:导入win32gui时DLL加载失败

导入ft2font时DLL加载失败:找不到指定的模块

Windows 上的 Tensorflow 安装:导入 _pywrap_tensorflow_internal 时 DLL 加载失败

如何修复cx_Oracle:DLL加载失败?

如何在python中的“导入错误:导入时DLL加载失败”中找到哪个DLL失败?

无法导入Orekit-“ DLL加载失败”

python tensorflow导入dll加载失败

无法从pywinauto导入:ImportError:导入win32ui时DLL加载失败:动态链接库(DLL)初始化例程失败