简体   繁体   English

Pyinstaller Win32 Qt应用程序无法正常工作

[英]Pyinstaller win32 qt app not working

I have 2 virtual machines with win32 and win64 . 我有2个具有win32win64的虚拟机。 I build program with PyQt5 and package it with PyInstaller(3.3.1), by using following command: 我使用以下命令构建PyQt5程序,并将其与PyInstaller(3.3.1)打包:

pyinstaller updater.py --noconsole --onefile -i icons/icon.ico

When I do this on win64 machine, it works fine. 当我在win64机器上执行此操作时,它工作正常。 Program working. 程序工作。 But when I do the same on win32 machine, my generated .exe file began require Admin privileges and even after confirm app is crashed. 但是,当我在win32机器上执行相同操作时,即使确认应用程序崩溃后,我生成的.exe文件也开始需要管理员权限。 I checked this question: Why does my pyinstaller created executable require admin privileges? 我检查了以下问题: 为什么我的pyinstaller创建的可执行文件需要管理员权限?

and rename app, but it still crashing. 并重命名应用,但仍然崩溃。 What can cause this ? 是什么原因造成的? Why on win32 defender blocks my app or maybe reason is not in defender. 为什么在win32防御程序上阻止我的应用程序,或者原因可能不在防御程序中。

class MainWindow(QtWidgets.QMainWindow):

    def __init__(self):
        super(MainWindow, self).__init__(flags=QtCore.Qt.Dialog)
        self.progress_bar = QtWidgets.QProgressBar()
        self.progress_label = QtWidgets.QLabel()
        central_widget = QtWidgets.QWidget(flags=QtCore.Qt.Widget)
        central_layout = QtWidgets.QVBoxLayout()
        central_layout.addWidget(self.progress_bar)
        central_layout.addWidget(self.progress_label, alignment=QtCore.Qt.AlignLeft)
        central_widget.setLayout(central_layout)
        self.setCentralWidget(central_widget)
        self.progress_label.setStyleSheet('color: grey')


def main():
    application = QtWidgets.QApplication(sys.argv)

    main_window = MainWindow()
    main_window.setFixedSize(480, 120)
    main_window.show()

    sys.exit(application.exec_())


if __name__ == '__main__':
    main()

requirements.txt: requirements.txt:

PyInstaller==3.3.1
PyQt5==5.10.1
requests==2.18.4

The problem was because I use python 3.7, but PyIntaller not support 3.7 yet. 问题是因为我使用python 3.7,但是PyIntaller还不支持3.7。 With 3.6 works fine, but still ask Admin Rights... 使用3.6可以正常使用,但仍要询问管理员权限...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM