python - 尝试使用 "pyinstaller <scriptname.py>"并得到 "TypeError: an integer is required (got type bytes)"

标签 python python-3.x pyqt pyqt5 pyinstaller

我想通过 python 创建一个简单的是/否消息框作为一个可执行文件。使用 pyqt5 并尝试使用 pyinstaller.Got 和错误生成可执行文件

TypeError: an integer is required (got type bytes).

使用命令后pyinstaller <scriptname.py>

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QMessageBox , QDesktopWidget
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import pyqtSlot

class 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_())

最佳答案

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

尽量使用兼容python 3.8的最新版本

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

这个解决方案对我有用

关于python - 尝试使用 "pyinstaller &lt;scriptname.py>"并得到 "TypeError: an integer is required (got type bytes)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58095877/

相关文章:

python - 将 PyQt5 添加到 `install_require`

python - OpenCV:Canny 边缘检测器获得 minEnclosingCircle

python - 在Python中使用concurrent.futures.ProcessPoolExecutor时为每个进程创建一个单独的记录器

python - 不定期重采样

python - 如何使窗口输出适合小部件

python - PyQt:如何从 Qt Designer 加载多个 .ui 文件

python - 了解 _tf_sess()

python - 在某个时间点内,二元组在列表中出现的次数

Python - os.rename() - OSError : [WinError 123]

python - 如何获取Pyqt5表格小部件中的行和列位置(通过鼠标事件突出显示)?