为了账号安全,请及时绑定邮箱和手机立即绑定

尝试使用“pyinstaller <scriptname.py>”

尝试使用“pyinstaller <scriptname.py>”

白衣非少年 2022-06-07 16:36:44
我想通过python创建一个简单的是/否消息框作为一个可执行文件。使用 pyqt5 并尝试使用 pyinstaller.Got 和错误生成可执行文件TypeError: an integer is required (got type bytes).使用命令后pyinstaller <scriptname.py>import sysfrom PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QMessageBox , QDesktopWidgetfrom PyQt5.QtGui import QIconfrom PyQt5.QtCore import pyqtSlotclass App(QWidget):    def __init__(self):        super().__init__()        self.initUI()    def center(self):        # geometry of the main window        qr = self.frameGeometry()        # center point of screen        cp = QDesktopWidget().availableGeometry().center()        # move rectangle's center point to screen's center point        qr.moveCenter(cp)        # top left of rectangle becomes top left of window centering it        self.move(qr.topLeft())    def initUI(self):        self.center()        buttonReply = QMessageBox.question(self, 'PyQt5 message', "Do you like PyQt5?",                                           QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel, QMessageBox.Cancel)        if buttonReply == QMessageBox.Yes:            print('Yes clicked.')        if buttonReply == QMessageBox.No:            print('No clicked.')        if buttonReply == QMessageBox.Cancel:            print('Cancel')        self.show()if __name__ == '__main__':    app = QApplication(sys.argv)    ex = App()    sys.exit(app.exec_())
查看完整描述

2 回答

?
冉冉说

TA贡献1877条经验 获得超1个赞

我在某人的评论中找到答案。

尝试使用与 python 3.8 兼容的最新版本。

pip install https://github.com/pyinstaller/pyinstaller/archive/develop.tar.gz

这个解决方案对我有用


查看完整回答
反对 回复 2022-06-07
?
呼如林

TA贡献1798条经验 获得超3个赞

PyInstaller 目前不支持 3.8。我建议您使用 3.7 或更早版本构建,直到支持 python 3.8



查看完整回答
反对 回复 2022-06-07
  • 2 回答
  • 0 关注
  • 154 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号