I Installed PyQt6 and cxfreeze on msys2-mingw-w64
But After Compiling python file, shown in console Just ['Windows', 'Fusion'] Style
here is setup.py of cxfreeze
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need
# fine tuning.
build_options = {'packages': [], 'excludes': []}
import sys
base = 'Win32GUI' if sys.platform=='win32' else None
executables = [ Executable('un.py', base=base)]
setup(name='qt',
version = '1.0',
description = '',
options = {'build_exe': build_options},
executables = executables)
And The python file:
from PyQt6 import QtCore, QtGui, QtWidgets
import sys
print(QtWidgets.QStyleFactory().keys()) # Print Available Qt6 Styles
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.progressBar = QtWidgets.QProgressBar(self.centralwidget)
self.progressBar.setGeometry(QtCore.QRect(30, 260, 731, 23))
self.progressBar.setProperty("value", 24)
self.progressBar.setObjectName("progressBar")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(220, 380, 371, 25))
self.pushButton.setObjectName("pushButton")
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Win"))
self.pushButton.setText(_translate("MainWindow", "Button"))
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec())
I Tried to copy C:\msys2\mingw64\usr\share\qt6\plugins
to Output EXE Directory andlib\PyQt6
.
Try setting the environment variable QT_PLUGIN_PATH, for example in a Command Prompt, before running the EXE file, like this:
SET QT_PLUGIN_PATH=C:\msys2\mingw64\usr\share\qt6\plugins
You can also run the EXE files that are not working through Dependency Walker to see if any dependency DLL files are missing. Because you definitely have them all in the same folder as the EXE files (e.g. DLLs from Qt and all its dependencies).
I wrote a tool as part of the pedeps project to copy dependency DLL files along with EXE file(s) (copypedeps -r
). You can use that to automatically copy all dependencies.