[Python] QtWebEngineView not working after compiling with nuitka in Python

Discussão em 'Python' iniciado por Stack, Julho 9, 2025.

  1. Stack

    Stack Membro Participativo

    Took some of the code from my launcher. I display the window with the site through PySide2 and QWebEngineView. Everything works fine with Python IDLE. When I compile with nuitka, the code crashes. If I output a normal window without the web module, everything works fine. Here is the code itself:

    from PySide2 import QtCore, QtGui, QtWidgets
    from PySide2.QtWidgets import QApplication, QMainWindow, QPushButton, QVBoxLayout, QWidget
    from PySide2.QtWebEngineWidgets import QWebEngineView
    import logging

    class Ui_MainWindow(object):

    def setupUi(self, MainWindow):

    MainWindow.setObjectName("MainWindow")
    MainWindow.resize(1000, 700)
    MainWindow.setBaseSize(QtCore.QSize(0, 0))

    # window

    self.centralwidget = QtWidgets.QWidget(self)
    self.setCentralWidget(self.centralwidget)
    self.centralwidget.setObjectName("centralwidget")
    font = QtGui.QFont()
    font.setFamily("Segoe UI Semibold")

    self.main_window_frame = QtWidgets.QFrame(self.centralwidget)
    self.main_window_frame.setGeometry(QtCore.QRect(5, 10, 1000, 700))
    self.main_window_frame.setStyleSheet("background-color: rgb(54,57,62)")
    self.main_window_frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
    self.main_window_frame.setFrameShadow(QtWidgets.QFrame.Raised)
    self.main_window_frame.setObjectName("main_window_frame")

    # (dont ask me what is it)

    self.tab_menu_frame3 = QtWidgets.QFrame(self.main_window_frame)
    self.tab_menu_frame3.setGeometry(QtCore.QRect(0, 50, 1000, 650))
    self.tab_menu_frame3.setStyleSheet("background-color: rgb(54,57,62)")
    self.tab_menu_frame3.setFrameShape(QtWidgets.QFrame.StyledPanel)
    self.tab_menu_frame3.setFrameShadow(QtWidgets.QFrame.Raised)
    self.tab_menu_frame3.setObjectName("tab_menu_frame3")

    # web engine
    self.web_view = QWebEngineView(self.main_window_frame)
    self.web_view.setGeometry(QtCore.QRect(0, 50, 1000, 650))
    self.web_view.setUrl(QtCore.QUrl('https://example.com'))
    try:
    self.web_view.show()
    except Exception as e:
    logging.error(f"Error: {e}")

    class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
    def __init__(self):
    super().__init__()
    self.setupUi(self)
    self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
    self.setAttribute(QtCore.Qt.WA_TranslucentBackground)

    if __name__ == '__main__':
    import sys
    app = QtWidgets.QApplication(sys.argv)
    try:
    w = MainWindow()
    w.show()
    sys.exit(app.exec_())
    except Exception as e:
    logging.error(f"Error: {e}")


    nuitka options:

    python -m nuitka --onefile --windows-console-mode=force --enable-plugin=pyside2 --standalone test.pyw


    The console (cmd C:\test.exe) displays this:

    QtWebEngine resources not found at C:/Temp/ONEFIL~1/PySide2/resources... Trying parent directory…

    Qt WebEngine resources not found at C:/Temp/ONEFIL~1/PySide2... Trying application directory…

    Qt WebEngine resources not found at C:/Temp/onefile_9968_133754483410059208. Trying fallback directory… The applicatio

    n MAY NOT work.

    Installed Qt WebEngine locales directory not found at location C:/Temp/ONEFIL~1/PySide2/translations\qtwebengine_locales

    Trying application directory…

    Qt WebEngine locales directory not found at location C:/Temp/onefile_9968_133754483410059208\qtwebengine_locales. Trying

    fallback directory… Translations MAY NOT not be correct.

    [1107/151902.529:ERROR: icu_util.cc (251)] Couldn't mmap icu data file

    [​IMG]
    I tried changing the code from PyQt5 to PySide2 because I thought nuitka with PyQt5 was compiling qtwebengineview with errors, but nothing changed. Tried changing nuitka parameters, nothing changed. I expected it to be easier

    Continue reading...

Compartilhe esta Página