I\'m trying to build an app using pyinstaller, PyQt5 and qml (see files below) using the following command.
pyrcc5 pyqt5_qml.qrc > pyqt5_qml_qrc.py
pyinst
Working with PyInstaller I've noticed that it simply fails to bundle QML dependencies then freezing an app. You can check whether it is your case as well by copying QtQuick and QtQuick.2 folders from python site packages () and placing it near freezed executable:
QtQuick
QtQuick.2
your_executable.exe
If app works after this, you can edit .spec file to bundle these folders automatically (pyinstaller generate .spec-file on first run).
# -*- mode: python -*-
import os
import site
block_cipher = None
site_packages_dir = site.getsitepackages()[1]
qml_dir = os.path.join(site_packages_dir, 'PyQt5', 'Qt', 'qml')
added_files = [
(os.path.join(qml_dir, 'QtQuick'), 'QtQuick'),
(os.path.join(qml_dir, 'QtQuick.2'), 'QtQuick.2'),
]
a = Analysis(['pyqt5_qml.py'],
binaries=None,
datas=added_files,
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='app',
debug=False,
strip=False,
upx=False,
console=True,
)
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
name='pyqt5_qml')
Then try to run pyinstaller against this spec-file: pyinstaller pyqt5_qml.spec