I have made simple application with tkinter
and json
libraries. The complexity is quiet big because there are few classes in separated .py files which are "tree-like connected". The script itself works perfectly but once I use pyinstaller
to make it into .exe file this error occurs.
Execute error:
Line 8 Erro:
I am using 2 pictures, one as background and second one as a frame picture, 1 label and 1 textbox. Even when I manually add images folder into dist folder it does not help.
Build command is as follows:
venv\Scripts\pyinstaller.exe Editor.py --distpath ./Ready_For_Testing --workpath ./temp_build --specpath ./spec_build -w --hidden-import tkinter
CodePudding user response:
Well I have just solved this issue even so it is manual solving.
If you use virtual enviroment you should go in your enviroment for example mine: D:\GitHub\SnA-KPIS-JSON-Editor\20_Implementation\venv
If you use system/allFor Python go inside your Python, path could look like this : C:\Users\YourLogin\Programs\PythonX.X
Inside in the Python folder copy folder named Library and just paste it inside your folder with .exe file. File you built with pyinstaller.
Feel free to remove any other folders inside Library but bin, that must stay. It's key to solve the issue.
If you have images which are used in tkinter
you have to copy and paste them inside your build folder as well.
It's simple and easily done. Hope this will help some others who will face the same issue.
EDIT: I found out that there is a way to solve this by adding more options inside your pyinstaller
command.
Command:
pyinstaller.exe Editor.py --distpath ./Ready_For_Testing --workpath ./temp_build --specpath ./spec_build --paths D:\GitHub\SnA-KPIS-JSON-Editor\20_Implementation\venv\Library\bin --hidden-import tkinter --hidden-import tkinter.filedialog --collect-all tkinter --windowed --hidden-import tkinter.messagebox
Main thing in the command is that you have to detect missing libraries/dlls which you can find inside stdout while "installing" .exe file.
Here is exact Warning output which you should look for in case of similar or same problem:
674 WARNING: lib not found: liblzma.dll dependency of D:\GitHub\SnA-KPIS-JSON-Editor\20_Implementation\venv\DLLs\_lzma.pyd
690 WARNING: lib not found: LIBBZ2.dll dependency of D:\GitHub\SnA-KPIS-JSON-Editor\20_Implementation\venv\DLLs\_bz2.pyd
721 WARNING: lib not found: ffi.dll dependency of D:\GitHub\SnA-KPIS-JSON-Editor\20_Implementation\venv\DLLs\_ctypes.pyd
737 WARNING: lib not found: tk86t.dll dependency of D:\GitHub\SnA-KPIS-JSON-Editor\20_Implementation\venv\DLLs\_tkinter.pyd
737 WARNING: lib not found: tcl86t.dll dependency of D:\GitHub\SnA-KPIS-JSON-Editor\20_Implementation\venv\DLLs\_tkinter.pyd
When you take a look inside Library\bin folder inside enviroment there you can see these missing files. And that is why you have to add them in --paths
option.