0
votes

I'm getting a "blank canvas" when using PyInstaller to package and application that utilizes QWebEngineView. Any help would be greatly appreciated!

Here's some code to reproduce the problem...

The following code runs fine with 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_())

but after packaging with pyinstaller toy.py nothing is shown.

The python application shows: enter image description here

while the pyinstaller application shows: enter image description here

1

1 Answers

0
votes

So this appears to be a bug in pyinstaller that can be patched by creating a specific file for PyQt.

The first clue in debugging this problem is to take note that QtWebEngineProcess.exe starts (as seen in the Task Manager) when we start from python, but it does not start with our application with pyinstaller. Upon inspection a log is written next to the pyinstaller copy of the QtWebEngineProcess.exe that doesn't really give a helpful message, but it does give a clue that the *.exe was attempted to start and crashed.

It appears that adding a qt.conf to dist/<app>/PyQt5/Qt/bin with the contents

[Paths]
Prefix = ..

fixed my problem.