Start by creating a project and a virtual environment.
mkdir pyside6nuitka cd pyside6nuitka/ python3 -m venv env
Activate the virtual environment and pip install nuitka and pyside6.
source env/bin/activate pip install nuitka pip install pyside6
Here is a pip list directory:
pip list Package Version ---------- -------- Nuitka 0.6.16.2 pip 20.2.3 PySide6 6.1.2 setuptools 49.2.1 shiboken6 6.1.2
Create main.py and enter the following code to create a window:
import sys from PySide6.QtWidgets import QApplication from PySide6.QtWidgets import QMainWindow from PySide6.QtGui import QScreen app = QApplication(sys.argv) mainwindow = QMainWindow() mainwindow.setGeometry(0, 0, 800, 600) mainwindow.show() app.exec()
Run python3 main.py
and see the result:
python3 -m nuitka --follow-imports --enable-plugin=pyside6 --standalone main.py
The following question is asked:
Nuitka will make use of ccache to speed up repeated compilation. Is it OK to download and put it in '/Users/loek/Library/Application Support/Nuitka/ccache/v4.2.1'. No installer needed, cached, one time question. Proceed and download? [Yes]/No
I Answer with n
(No) and the compiling continues until the end:
Nuitka:INFO: Successfully created 'main.dist/main'.
At this point, you can execute the binary with the command:
main.dist/main
An error occurs:
ImportError: dlopen(../dev/pyside6nuitka/./main.dist/PySide6/QtWidgets.so, 2): Library not loaded: @rpath/QtQml.framework/Versions/A/QtQml Referenced from: ..dev/pyside6nuitka/main.dist/libpyside6.abi3.6.1.dylib Reason: image not found
The problem is that qml files are missing in main.dist/main
.
main.dist/PySide6
pyside6nuitka/env
...../env/lib/python3.9/site-packages/PySide6/Qt
to the package contents main.dist/PySide6
folder.Result with Qt folder in main.dist/PySide6
:
Execute again:
main.dist/main
This time it works.
I can copy main.dist to another machine and it works there too.