PyInstaller不编译PyQt5程序

时间:2019-07-18 09:06:20

标签: python pyqt

我用PyQt5构建了一个计算器,该计算器支持深色主题(qdarkstyle),快捷方式,信号以及基本计算器应具备的所有功能。该代码的工作方式与PyCharm中的预期目的相同。

我试图从程序中删除qdarkstyle,图标和其他功能,只是为了尝试代码是否有错误,但仍然没有结果。如果有必要,我将包含main.py

中的整个代码
from PyQt5 import QtWidgets
from qt import main #main.py is the generated file from Qt Designer
import qdarkstyle
import sys

class MyWin(main.Ui_MainWindow, QtWidgets.QMainWindow):
    def __init__(self):
        super().__init__()

        self.initUI()
        self.signals()


    def initUI(self):
        self.setupUi(self)
        self.show()
        self.setFixedSize(350, 150)
        self.clear.setStatusTip('Clears the screen') #clear is QPushButtton
        self.calculate.setStatusTip('Calculates the sum') #QPushButton
        self.comboBox.setStatusTip('Select an operator')
        self.quit.setStatusTip('Exits the program') #QAction in QMenu
        self.themes.setStatusTip('Chooses between light and dark theme')

    def signals(self):
        self.calculate.clicked.connect(self.calc) #QPushButton
        self.themes.triggered.connect(self.darktheme) #QAction in QMenu

    def calc(self):
        a = self.num1.text()
        b = self.num2.text()
        op = self.comboBox.currentText()
        try:
            c = eval(a + op + b)
            self.chislo.setText(str(c))
        except:
            self.signals()

    def darktheme(self):
        if self.themes.isChecked():
            self.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
            self.setFixedSize(350, 170)
            self.equal.setFixedSize(20, 10)
        else:
            self.initUI()
            self.signals()
            self.setStyleSheet('WindowsVista')


if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    GUI = MyWin()
    sys.exit(app.exec_())

我希望PyInstaller能够编译程序并像在PyCharm中一样运行。我收到很多警告,例如:

找不到a)lib:api-ms-win-crt ...- 11-1-0.dll依赖项。这是一个:api-ms-win-crt-locale-11-1-0.dll

在这些错误之后进行编译时,该程序将立即关闭。

0 个答案:

没有答案