0

Когда я пытаюсь скомпилировать код, у меня выходит вот такая ошибка:

110 INFO: PyInstaller: 3.4
110 INFO: Python: 3.5.2
110 INFO: Platform: Windows-7-6.1.7601-SP1
112 INFO: wrote C:\Users\Sheih\Desktop\programmer\Svoe\ChangeDataDate\ChangeData
Date.spec
113 INFO: UPX is not available.
115 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Sheih\\Desktop\\programmer\\Svoe\\ChangeDataDate',
 'C:\\Users\\Sheih\\Desktop\\programmer\\Svoe\\ChangeDataDate']
116 INFO: checking Analysis
116 INFO: Building Analysis because Analysis-00.toc is non existent
116 INFO: Initializing module dependency graph...
119 INFO: Initializing module graph hooks...
121 INFO: Analyzing base_library.zip ...
5075 INFO: running Analysis Analysis-00.toc
5568 INFO: Caching module hooks...
5577 INFO: Analyzing C:\Users\Sheih\Desktop\programmer\Svoe\ChangeDataDate\Chang
eDataDate.py
5605 INFO: Loading module hooks...
5605 INFO: Loading module hook "hook-PyQt5.py"...
5715 WARNING: Cannot read QLibraryInfo output: raised Expecting value: line 1 co
lumn 1 (char 0) when decoding:
Traceback (most recent call last):
  File "<string>", line 11, in <module>
TypeError: __call__() got an unexpected keyword argument 'qualname'
Traceback (most recent call last):
  File "c:\python35\lib\runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python35\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python35\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
  File "c:\python35\lib\site-packages\PyInstaller\__main__.py", line 111, in run

    run_build(pyi_config, spec_file, **vars(args))
  File "c:\python35\lib\site-packages\PyInstaller\__main__.py", line 63, in run_
build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\python35\lib\site-packages\PyInstaller\building\build_main.py", line
838, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'
))
  File "c:\python35\lib\site-packages\PyInstaller\building\build_main.py", line
784, in build
    exec(text, spec_namespace)
  File "<string>", line 17, in <module>
  File "c:\python35\lib\site-packages\PyInstaller\building\build_main.py", line
241, in __init__
    self.__postinit__()
  File "c:\python35\lib\site-packages\PyInstaller\building\datastruct.py", line
158, in __postinit__
    self.assemble()
  File "c:\python35\lib\site-packages\PyInstaller\building\build_main.py", line
500, in assemble
    module_hook.post_graph()
  File "c:\python35\lib\site-packages\PyInstaller\building\imphook.py", line 410
, in post_graph
    self._load_hook_module()
  File "c:\python35\lib\site-packages\PyInstaller\building\imphook.py", line 377
, in _load_hook_module
    self.hook_module_name, self.hook_filename)
  File "c:\python35\lib\site-packages\PyInstaller\compat.py", line 736, in impor
tlib_load_source
    return mod_loader.load_module()
  File "<frozen importlib._bootstrap_external>", line 388, in _check_name_wrappe
r
  File "<frozen importlib._bootstrap_external>", line 809, in load_module
  File "<frozen importlib._bootstrap_external>", line 668, in load_module
  File "<frozen importlib._bootstrap>", line 268, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 693, in _load
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "c:\python35\lib\site-packages\PyInstaller\hooks\hook-PyQt5.py", line 23,
 in <module>
    collect_system_data_files(pyqt5_library_info.location['PrefixPath'],
  File "c:\python35\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 67, i
n __getattr__
    qli = json.loads(json_str)
  File "c:\python35\lib\json\__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "c:\python35\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "c:\python35\lib\json\decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Сам код:

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets    import *
from PyQt5.QtCore       import *
from PyQt5.QtGui        import *
import time, sys, os


class Folder(QWidget):
    def __init__(self):
        super().__init__()
        self.setFixedSize(400, 225)
        self.way = 0

        self.calendar = QDateTimeEdit(self)
        self.calendar.setGeometry(10, 10, 380, 35)
        self.calendar.setDisplayFormat("dd.MM.yyyy | H:mm:ss")

        btnOpen = QPushButton(self)
        btnOpen.setText("Открыть папку")
        btnOpen.setGeometry(10, 55, 380, 50)
        btnOpen.clicked.connect(self.openFolder)

        self.wayText = QLineEdit(self)
        self.wayText.setGeometry(10, 115, 380, 40)
        self.wayText.setReadOnly(True)

        btnChange = QPushButton(self)
        btnChange.setText("Изменить")
        btnChange.setGeometry(10, 165, 380, 50)
        btnChange.clicked.connect(self.change)

    def change(self):
        if self.way != "":
            year = self.calendar.dateTime().toString("yyyy")
            month = self.calendar.dateTime().toString("MM")
            day = self.calendar.dateTime().toString("dd")
            hour = self.calendar.dateTime().toString("hh")
            minute = self.calendar.dateTime().toString("mm")
            second = self.calendar.dateTime().toString("ss")

            if year.startswith("0"):
                year = year[1:]
            if month.startswith("0"):
                month = month[1:]
            if day.startswith("0"):
                day = day[1:]
            if hour.startswith("0"):
                hour = hour[1:]
            if minute.startswith("0"):
                minute = minute[1:]
            if second.startswith("0"):
                second = second[1:]

    def openFolder(self):
        fname = QFileDialog.getExistingDirectory(self, "Select directory")
        self.way = fname
        self.wayText.setText(fname)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    ex = Folder()
    ex.show()
    sys.exit(app.exec_())

Ввожу для компиляции:

pyinstaller --onefile --icon=name.ico --noconsole myscript.py

2
  • Вам надо показать код и строку, которой вы пытаетесь скомпилировать код.
    – S. Nick
    4 июл 2019 в 13:50
  • @S.Nick Добавил
    – djimboy
    4 июл 2019 в 14:43

2 ответа 2

1

Я не знаю почему у вас так получается. У меня компилируется нормально, но иконка не появляется. Я обычно делаю так: - вставьте строку self.setWindowIcon(QtGui.QIcon("icono.png")) и компилируйте pyinstaller --onefile --noconsole myscript.py

myscript.py

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets    import *
from PyQt5.QtCore       import *
from PyQt5.QtGui        import *
import time, sys, os


class Folder(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowIcon(QtGui.QIcon("icono.png"))                 # <------------------------
        self.setFixedSize(400, 225)
        self.way = 0

        self.calendar = QDateTimeEdit(self)
        self.calendar.setGeometry(10, 10, 380, 35)
        self.calendar.setDisplayFormat("dd.MM.yyyy | H:mm:ss")

        btnOpen = QPushButton(self)
        btnOpen.setText("Открыть папку")
        btnOpen.setGeometry(10, 55, 380, 50)
        btnOpen.clicked.connect(self.openFolder)

        self.wayText = QLineEdit(self)
        self.wayText.setGeometry(10, 115, 380, 40)
        self.wayText.setReadOnly(True)

        btnChange = QPushButton(self)
        btnChange.setText("Изменить")
        btnChange.setGeometry(10, 165, 380, 50)
        btnChange.clicked.connect(self.change)

    def change(self):
        if self.way != "":
            year = self.calendar.dateTime().toString("yyyy")
            month = self.calendar.dateTime().toString("MM")
            day = self.calendar.dateTime().toString("dd")
            hour = self.calendar.dateTime().toString("hh")
            minute = self.calendar.dateTime().toString("mm")
            second = self.calendar.dateTime().toString("ss")

            if year.startswith("0"):
                year = year[1:]
            if month.startswith("0"):
                month = month[1:]
            if day.startswith("0"):
                day = day[1:]
            if hour.startswith("0"):
                hour = hour[1:]
            if minute.startswith("0"):
                minute = minute[1:]
            if second.startswith("0"):
                second = second[1:]

    def openFolder(self):
        fname = QFileDialog.getExistingDirectory(self, "Select directory")
        self.way = fname
        self.wayText.setText(fname)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    ex = Folder()
    ex.show()
    sys.exit(app.exec_())

icono.png

введите сюда описание изображения


Вот результат запуска myscript.exe

введите сюда описание изображения

1
  • Всё равно не помогает. Вылезает такая же ошибка.
    – djimboy
    5 июл 2019 в 7:44
0

Решил проблему.

Создал виртуальную среду: py -m venv venv Далее запустил среду: venv\Scripts\activate.bat После установил нужные модули: PyQt5, PyQt5-tools, sip, pyinstallerr

Ввёл: pyinstaller --onefile --icon=icon.ico --noconsole myscript.py

И файл скомпилировался

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.