【已解决】pyinstaller打包后出现ImportError: DLL load failed while importing QtWebEngineWidgets: 找不到指定的程序。

pyinstaller打包前可以正常运行,打包后ImportError: DLL load failed while importing QtWebEngineWidgets: 找不到指定的程序。

环境
  • IDE:PyCharm 2022.2.2 (Community Edition)
  • Python 版本:3.9
  • pyinstaller 版本:5.7
  • pyqt5 版本:5.15.7
使用的打包命令为
  • pyinstaller -w -D main.py
报错
  • pyinstaller打包前正常运行,打包后出现ImportError: DLL load failed while importing QtWebEngineWidgets: 找不到指定的程序。
  • 信心满满开始百度,以为是小bug,分分钟解决,没想到,搞了我1天多时间。
尝试一下方法均不能解决
  • 打包-p加包路径,pyinstaller -w -D -p 包路径 main.py,参考。
  • 将整个包复制到exe同目录下,参考。
  • 将整个包复制到exe同目录下,参考。
  • 重新安装pyqt5和 QtWebEngine,参考。
  • 升级pyinstaller,pip install --upgrade pyinstaller,参考。
  • qt.confQtWebEngineProcess.exe复制到到跟输出的exe文件同级的目录,修改qt.conf原内容 Prefix = .. Prefix = ./PyQt5/Qt,参考。
最后看到一篇blog说可能是pyinstaller版本问题
  • 于是降低pyinstaller版本到5.1,pip install pyinstaller==5.1
  • 打包成功后,正常运行!
  • 撒花!

你可能感兴趣的:(python,开发语言)