Jan-30-2025, 05:21 PM
I have an tkinter app that runs fine in VS-Code/Terminal, but I can't seem to get it to work as a standalone.
The error is always a variant on the theme below.
I've tried explicitly including tkdnd in the pyinstaller -datas tag
I've tried using a spec file to include it
I've placed copies in the dist/ folder
I've made sure that there's a copy of tkdnd under the tcl folder and not just under tkinter
I've tried adding it into the code
This is actually the first time that I've needed to use a GUI in compiled code (I need to give someone a drag and drop), so it may be something monumentally stupid and obvious that I'm missing. It does work flawlessly when I launch from VS, just not packaged.
I'm on Python 3.11 in a Windows 10 Enterprise environment with tkinterdnd2-0.4.2, tk8.6, tkdnd2.9.3
Any suggestions would be greatly appreciated.
Thanks for reading and thanks, in advance, for any suggestions.
The error is always a variant on the theme below.
Error:Traceback (most recent call last):
File "tkinterdnd2\TkinterDnD.py", line 55, in _require
_tkinter.TclError: can't find package tkdnd
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "BalanceBigNumbers.py", line 89, in <module>
File "tkinterdnd2\TkinterDnD.py", line 287, in __init__
File "tkinterdnd2\TkinterDnD.py", line 57, in _require
RuntimeError: Unable to load tkdnd library.
I've tried every suggestion that I could find online...I've tried explicitly including tkdnd in the pyinstaller -datas tag
I've tried using a spec file to include it
I've placed copies in the dist/ folder
I've made sure that there's a copy of tkdnd under the tcl folder and not just under tkinter
I've tried adding it into the code
import sys import os import pandas as pd import tkinter as tk from tkinter import scrolledtext from tkinterdnd2 import DND_FILES, TkinterDnD from decimal import Decimal # ✅ Use Decimal to prevent precision loss # Detect if running in a compiled PyInstaller environment if getattr(sys, 'frozen', False): base_path = sys._MEIPASS # PyInstaller extracts files to _MEIPASS else: base_path = os.path.dirname(os.path.abspath(__file__)) # Set the correct tkdnd path for TkinterDnD tkdnd_path = os.path.join(base_path, "tkdnd") ... root = TkinterDnD.Tk() root.tk.call("lappend", "auto_path", tkdnd_path) root.tk.call("package", "require", "tkdnd")I'm grasping at straws and not getting any kind of traction on this.
This is actually the first time that I've needed to use a GUI in compiled code (I need to give someone a drag and drop), so it may be something monumentally stupid and obvious that I'm missing. It does work flawlessly when I launch from VS, just not packaged.
I'm on Python 3.11 in a Windows 10 Enterprise environment with tkinterdnd2-0.4.2, tk8.6, tkdnd2.9.3
Any suggestions would be greatly appreciated.
Thanks for reading and thanks, in advance, for any suggestions.