B
B
badalcode2021-12-16 09:48:27
Python
badalcode, 2021-12-16 09:48:27

Error while compiling .py to .exe?

I can’t compile the file, when running normally through the console (py main.py) everything works fine, but when compiling, the Generate and Load file functions disappear. Help me figure out what the problem is.

Errors when uploading a file\generation:

Tyk
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

Compilation logs:
Tyk
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.

I can't upload the entire code (10k character limit), so I uploaded it here: https://my-files.su/j8nhyu

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
badalcode, 2021-12-16
@badalcode

In general, I solved the problem with the answer from this topic https://qna.habr.com/q/794317 . The solution may not be the best, as the author says, but it works.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question