Задать вопрос
@badalcode

Ошибка при компиляции .py в .exe?

Не могу скомпилировать файл, при обычном запуске через консоль (py main.py) всё работает отлично, но при компиляции функции Сгенерировать и Загрузить файл отпадают. Помогите разобраться в чём проблема.

Ошибки при загрузке файла\генерации:
Тык
Exception in Tkinter callback
Traceback (most recent call last):
File "tkinter\__init__.py", line 1892, in __call__
File "main.py", line 145, in uploadFile
File "barcode\base.py", line 82, in write
File "barcode\ean.py", line 121, in render
File "barcode\base.py", line 105, in render
File "barcode\writer.py", line 227, in render
File "barcode\writer.py", line 372, in _paint_text
File "PIL\ImageFont.py", line 855, in truetype
File "PIL\ImageFont.py", line 852, in freetype
File "PIL\ImageFont.py", line 211, in __init__
OSError: cannot open resource

Логи при компиляции:
Тык
86 INFO: PyInstaller: 4.4
86 INFO: Python: 3.9.6
105 INFO: Platform: Windows-10-10.0.19043-SP0
106 INFO: wrote C:\Users\admin\Desktop\Python\Barcode Generator GUI\main.spec
116 INFO: UPX is not available.
118 INFO: Extending PYTHONPATH with paths
['C:\\Users\\admin\\Desktop\\Python\\Barcode Generator GUI',
'C:\\Users\\admin\\Desktop\\Python\\Barcode Generator GUI']
127 INFO: checking Analysis
128 INFO: Building Analysis because Analysis-00.toc is non existent
128 INFO: Initializing module dependency graph...
131 INFO: Caching module graph hooks...
147 INFO: Analyzing base_library.zip ...
2729 INFO: Processing pre-find module path hook distutils from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
2730 INFO: distutils: retargeting to non-venv dir 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib'
5862 INFO: Caching module dependency graph...
6067 INFO: running Analysis Analysis-00.toc
6070 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\users\admin\appdata\local\programs\python\python39\python.exe
6129 WARNING: lib not found: api-ms-win-core-path-l1-1-0.dll dependency of c:\users\admin\appdata\local\programs\python\python39\python39.dll
6144 INFO: Analyzing C:\Users\admin\Desktop\Python\Barcode Generator GUI\main.py
7925 INFO: Processing module hooks...
7926 INFO: Loading module hook 'hook-openpyxl.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
8101 INFO: Loading module hook 'hook-difflib.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8103 INFO: Loading module hook 'hook-distutils.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8104 INFO: Loading module hook 'hook-distutils.util.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8106 INFO: Loading module hook 'hook-encodings.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8207 INFO: Loading module hook 'hook-heapq.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8211 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8271 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8275 INFO: Loading module hook 'hook-pickle.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8278 INFO: Loading module hook 'hook-PIL.Image.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8629 INFO: Loading module hook 'hook-PIL.ImageFilter.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8631 INFO: Loading module hook 'hook-PIL.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8641 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8644 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8645 INFO: Loading module hook 'hook-xml.dom.domreg.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8816 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8817 INFO: Loading module hook 'hook-xml.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8818 INFO: Loading module hook 'hook-_tkinter.py' from 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8969 INFO: checking Tree
8969 INFO: Building Tree because Tree-00.toc is non existent
8970 INFO: Building Tree Tree-00.toc
9055 INFO: checking Tree
9055 INFO: Building Tree because Tree-01.toc is non existent
9056 INFO: Building Tree Tree-01.toc
9155 INFO: checking Tree
9156 INFO: Building Tree because Tree-02.toc is non existent
9156 INFO: Building Tree Tree-02.toc
9204 INFO: Looking for ctypes DLLs
9220 INFO: Analyzing run-time hooks ...
9226 INFO: Including run-time hook 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
9230 INFO: Including run-time hook 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
9235 INFO: Including run-time hook 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
9237 INFO: Including run-time hook 'c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth__tkinter.py'
9248 INFO: Looking for dynamic libraries
9684 INFO: Looking for eggs
9685 INFO: Using Python library c:\users\admin\appdata\local\programs\python\python39\python39.dll
9685 INFO: Found binding redirects:
[]
9690 INFO: Warnings written to C:\Users\admin\Desktop\Python\Barcode Generator GUI\build\main\warn-main.txt
9784 INFO: Graph cross-reference written to C:\Users\admin\Desktop\Python\Barcode Generator GUI\build\main\xref-main.html
9840 INFO: checking PYZ
9840 INFO: Building PYZ because PYZ-00.toc is non existent
9840 INFO: Building PYZ (ZlibArchive) C:\Users\admin\Desktop\Python\Barcode Generator GUI\build\main\PYZ-00.pyz
10800 INFO: Building PYZ (ZlibArchive) C:\Users\admin\Desktop\Python\Barcode Generator GUI\build\main\PYZ-00.pyz completed successfully.
10826 INFO: checking PKG
10827 INFO: Building PKG because PKG-00.toc is non existent
10827 INFO: Building PKG (CArchive) PKG-00.pkg
10859 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
10862 INFO: Bootloader c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
10863 INFO: checking EXE
10863 INFO: Building EXE because EXE-00.toc is non existent
10864 INFO: Building EXE from EXE-00.toc
10866 INFO: Copying icons from ['c:\\users\\admin\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico']
10868 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
10868 INFO: Writing RT_ICON 1 resource with 3752 bytes
10869 INFO: Writing RT_ICON 2 resource with 2216 bytes
10869 INFO: Writing RT_ICON 3 resource with 1384 bytes
10870 INFO: Writing RT_ICON 4 resource with 37019 bytes
10870 INFO: Writing RT_ICON 5 resource with 9640 bytes
10871 INFO: Writing RT_ICON 6 resource with 4264 bytes
10871 INFO: Writing RT_ICON 7 resource with 1128 bytes
10875 INFO: Appending archive to EXE C:\Users\admin\Desktop\Python\Barcode Generator GUI\build\main\main.exe
11517 INFO: Building EXE from EXE-00.toc completed successfully.
11522 INFO: checking COLLECT
11522 INFO: Building COLLECT because COLLECT-00.toc is non existent
11523 INFO: Building COLLECT COLLECT-00.toc
13540 INFO: Building COLLECT COLLECT-00.toc completed successfully.

Не могу загрузить весь код (ограничение 10к символов), поэтому залил сюда: https://my-files.su/j8nhyu
  • Вопрос задан
  • 215 просмотров
Подписаться 1 Простой 1 комментарий
Решения вопроса 1
@badalcode Автор вопроса
В общем решил проблему ответом из этой темы https://qna.habr.com/q/794317. Решение может и не самое лучшее, как говорит автор, но работает.
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы