Reputation: 95
I have created an executable file using --onefile option with pyinstaller (pyside6 app) and it works fine on the windows computer on which it is created. When I run this file on another windows machine, if get the following error:
qt.qpa.plugin: Could not load the Qt platform plugin "windows" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: direct2d, minimal, offscreen, windows.
I have tried putting the platform folder with .dll files next to the executable but that doesn't solve this problem. Further, none of the suggestions mentioned in PyInstaller generated exe file error : qt.qpa.plugin: could not load the qt platform plugin "windows" in "" even though it was found and the thread therein have helped. Could you please let me know a possible way to fix this issue?
Below is an MWE having the two python source files and the pyinstaller spec file.
test_app.py
# -*- coding: utf-8 -*-
################################################################################
## Form generated from reading UI file 'test_app.ui'
##
## Created by: Qt User Interface Compiler version 6.3.1
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
QMetaObject, QObject, QPoint, QRect,
QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QLabel, QLineEdit, QMainWindow,
QPushButton, QSizePolicy, QStatusBar, QWidget)
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.resize(300, 150)
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget")
self.label = QLabel(self.centralwidget)
self.label.setObjectName(u"label")
self.label.setGeometry(QRect(10, 39, 41, 21))
self.enteredName = QLineEdit(self.centralwidget)
self.enteredName.setObjectName(u"enteredName")
self.enteredName.setGeometry(QRect(70, 40, 113, 20))
self.showHi = QLineEdit(self.centralwidget)
self.showHi.setObjectName(u"showHi")
self.showHi.setGeometry(QRect(80, 100, 113, 20))
self.run = QPushButton(self.centralwidget)
self.run.setObjectName(u"run")
self.run.setGeometry(QRect(210, 40, 56, 17))
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QStatusBar(MainWindow)
self.statusbar.setObjectName(u"statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QMetaObject.connectSlotsByName(MainWindow)
# setupUi
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None))
self.label.setText(QCoreApplication.translate("MainWindow", u"Name", None))
self.run.setText(QCoreApplication.translate("MainWindow", u"Run", None))
# retranslateUi
The main file (test_MWE.py)
import sys
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QLineEdit, QFileDialog
from test_app import Ui_MainWindow
def showMessage():
window.ui.showHi.setText("HI "+window.ui.enteredName.text())
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.show()
window.ui.run.clicked.connect(showMessage)
sys.exit(app.exec())
The test_MWE.spec file
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(
['test_MWE.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='test_MWE',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
Recap, I am compiling the executable with --onefile option on windows 11. The resulting file is working as expected. On running the executable file on Windows 7, I am getting the error given above.
Upvotes: 1
Views: 420
Reputation: 48454
Qt6 was never intended to work on versions older than Windows 10, as explained in the early blog post about hosts and targets, and as can be seen in the official documentation about the supported platforms.
If you need your program to also work on Windows <10, you must use Qt5.
Upvotes: 0