PySide6-QtQuick & QML problem generating an executable with NUITKA
-
wrote on 25 Feb 2025, 10:25 last edited by Rivet
Hello,
Please, I would like to find a solution to a problem that my research has not been able to solve. I am coding in Python and I started with QtQuick-QML to develop modern graphical applications with Python - PySide6, but I am facing an issue. When I compile my project with Nuitka to obtain a standalone executable using the command:bash
python -m nuitka --onefile --windows-console-mode=disable --enable-plugin=pyside6 --include-qt-plugins=qml --include-data-files=gui.qml=gui.qml main.py
The resulting executable is about 100MB even though the code is very lightweight, and I also notice the inclusion of modules like QtWebEngine and QtWebEngineCore, etc.Here is the code contained in my main.py file:
import sys from PySide6.QtQml import QQmlApplicationEngine from PySide6.QtGui import QGuiApplication if __name__ == "__main__": app = QGuiApplication(sys.argv) engine = QQmlApplicationEngine() engine.load("gui.qml") sys.exit(app.exec())
And here is the code contained in my gui.qml file for the graphical interface:
import QtQuick import QtQuick.Controls Window { width: 640 height: 480 visible: true title: "A simple button in the window" Button { text: "Push me" anchors.centerIn: parent width: 200 } }
I have tried many solutions, such as using the options: --noinclude-qt-plugins=qtwebengine,qtwebenginecore,qtwebenginewidgets,qtwebenginequick and also --nofollow-import-to=PySide6.QtWebEngine,PySide6.QtWebEngineCore,PySide6.QtWebEngineWidgets,PySide6.QtWebEngineQuick --include-data-files=gui.qml=gui.qml main.py, but nothing seems to work.
Thank you in advance for your future responses!!!
-
Hello,
Please, I would like to find a solution to a problem that my research has not been able to solve. I am coding in Python and I started with QtQuick-QML to develop modern graphical applications with Python - PySide6, but I am facing an issue. When I compile my project with Nuitka to obtain a standalone executable using the command:bash
python -m nuitka --onefile --windows-console-mode=disable --enable-plugin=pyside6 --include-qt-plugins=qml --include-data-files=gui.qml=gui.qml main.py
The resulting executable is about 100MB even though the code is very lightweight, and I also notice the inclusion of modules like QtWebEngine and QtWebEngineCore, etc.Here is the code contained in my main.py file:
import sys from PySide6.QtQml import QQmlApplicationEngine from PySide6.QtGui import QGuiApplication if __name__ == "__main__": app = QGuiApplication(sys.argv) engine = QQmlApplicationEngine() engine.load("gui.qml") sys.exit(app.exec())
And here is the code contained in my gui.qml file for the graphical interface:
import QtQuick import QtQuick.Controls Window { width: 640 height: 480 visible: true title: "A simple button in the window" Button { text: "Push me" anchors.centerIn: parent width: 200 } }
I have tried many solutions, such as using the options: --noinclude-qt-plugins=qtwebengine,qtwebenginecore,qtwebenginewidgets,qtwebenginequick and also --nofollow-import-to=PySide6.QtWebEngine,PySide6.QtWebEngineCore,PySide6.QtWebEngineWidgets,PySide6.QtWebEngineQuick --include-data-files=gui.qml=gui.qml main.py, but nothing seems to work.
Thank you in advance for your future responses!!!
@Rivet Please use https://forum.qt.io/category/57/french if you want to ask in French
-
Hi,
Which version of PySide6 would that be ?
Which version of Nuitka ?
On which OS ?
Also, while the logs nuitka might mention webengine, are you sure it's actually included ?
I did a test on macOS and ended up with a 84MB binary which is not that surprising accounting for the QtQuick stuff plus QtCore and QtGui.
1/4