Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tried to use "pyinstaller <scriptname.py>" and got "TypeError: an integer is required (got type bytes)"

I want to create a simple yes/no messagebox as one executable file by python. Used pyqt5 and tried make excecutable file with pyinstaller.Got and error

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

after using command 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_())
like image 807
олег олегов Avatar asked Sep 25 '19 10:09

олег олегов


1 Answers

I found the answer here in someone's comment.

Try to use the latest version compatible with python 3.8.

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

This solution worked for me

like image 105
Creed Deskenth Avatar answered Nov 09 '22 23:11

Creed Deskenth