【问题标题】:QWebEngineView not working with PyInstallerQWebEngineView 不适用于 PyInstaller
【发布时间】:2020-10-30 20:30:29
【问题描述】:

在使用 PyInstaller 打包和使用 QWebEngineView 的应用程序时,我得到了一个“空白画布”。任何帮助将不胜感激!

这里有一些代码可以重现问题...

以下代码在 python 上运行良好:

import sys

from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtCore import QUrl

if __name__ == '__main__':
    app = QApplication(sys.argv)

    view = QWebEngineView()
    view.resize(1024, 600)
    view.load(QUrl('http://www.google.com'))
    view.show()

    sys.exit(app.exec_())

但是在使用pyinstaller toy.py 打包后没有显示任何内容。

python 应用程序显示:

当 pyinstaller 应用程序显示时:

【问题讨论】:

    标签: pyqt5 pyinstaller


    【解决方案1】:

    所以这似乎是 pyinstaller 中的一个错误,可以通过为 PyQt 创建特定文件来修补。

    调试这个问题的第一个线索是注意当我们从 python 启动时 QtWebEngineProcess.exe 启动(如在任务管理器中看到的),但它不会从我们的应用程序启动 pyinstaller。经检查,在 QtWebEngineProcess.exe 的 pyinstaller 副本旁边写入了一个日志,该日志并没有真正给出有用的消息,但它确实提供了 *.exe 试图启动并崩溃的线索。

    似乎将qt.conf 添加到dist/<app>/PyQt5/Qt/bin 的内容

    [Paths]
    Prefix = ..
    

    解决了我的问题。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-04
    • 1970-01-01
    • 2022-06-20
    • 2021-09-20
    • 1970-01-01
    相关资源
    最近更新 更多