I'm trying to package my project into an executable file using pyinstaller. main.py, my program, should run when I run the exe file. Exe because program has to run somehow without the user, who is not a developer in any way, needing to install modules and python itself. If there's a better/easier way please do tell me.
i installed tkinterdnd2 by using pip install tkinterdnd2
.
Not sure if this is necessary, but here is the directory of the program: (the pngs are only used for my program, I don't think that is the culprit):
Folder
- cardiologist.png
- img.png
.
. # a couple more pngs
.
- main.py
- patients' data csv.csv
- patients' data xlsx test.xlsx
- sample.xlsx
- sun-valley.tcl #this file and the 'theme' folder below are for my program's theme, also don't think these are the culprit
- theme
- dark
- a lot of pngs...
- dark.tcl
- light
- a lot of pngs...
- light.tcl
Pyinstaller created 2 files, build
and dist
as expected.
build
- main
- base_library.zip
- certifi
- IPython
- jedi
- (some other files)
.
. a lot of .dylib files
.
- main # exe file to execute to run program
- matplotlib (this and next 4 are folders)
- numpy
- pandas
- parso
- PIL
- Python # exe file, don't know what this was created for
- (some more folders)
- tcl (this and next 2 are folders)
- tcl8
- 8.4
- platform
- .tm file
- .tm file
- 8.5
- 2 .tm files
- 8.6
- .tm file
- tdbc
- .tm file
- tkdnd2.8 (tried renaming to just tkdnd but same error)
- tk
- ttkwidgets
- 2 other folders
The command I used:
python -m PyInstaller main.py. # without python -m, 'command not found error' would happen
Error when running the produced exe:
Traceback (most recent call last):
File "tkinterdnd2/TkinterDnD.py", line 53, in _require
_tkinter.TclError: can't find package tkdnd
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 16, in <module>
File "tkinterdnd2/TkinterDnD.py", line 285, in __init__
File "tkinterdnd2/TkinterDnD.py", line 55, in _require
RuntimeError: Unable to load tkdnd library.
[7015] Failed to execute script 'main' due to unhandled exception!
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
I've went on the internet and tried looking for answers, but they either did not work for me, or wasn't clear enough like this: *.py script with tkinterdnd2 module doesn`t compile to an executable file (this solution still gave me the same error).
I've also tried using other modules to package such as cx_freeze and py2app, but both produced a different error, so I went back to pyinstaller for now. I'm on macOS.
Any way to fix this error?
EDIT
also tried python -m PyInstaller --clean -y -n "output_name" --add-data="tkdnd:tkdnd" main.py
but same error produced when running.