Skip to content Skip to sidebar Skip to footer

*.py Script With Tkinterdnd2 Module Doesn`t Compile To An Executable File

I made an app that uses tkinter and tkinterdnd moudles. It works completely fine when I launch it as a script, however when I try to make and executable file from it and laucnh it,

Solution 1:

The issue here is that Drag n Drop requires two components: the TCL libraries and the Tkinter interface to them. I install both manually to config my environment. (See my answer to How to Install and Use TkDnD with Python Tkinter on OSX?). I know someone packaged something on PyPI for the TkinterDnD2, but I haven't looked into it.

I have a project which uses TkinterDnD2. I build it with PyInstaller and see the same error you see (more or less). Running PyInstaller with the --onedir option (rather than the --onefile option), I saw that tkdnd2.8 was missing from my dist directory.

To rectify this, on Windows, I added

--add-binary "C:/Python/Python38-32/tcl/tkdnd2.8;tkdnd2.8"

to the PyInstaller command line, and that did the trick. I can now build a --onefile executable, and it runs without error.

Solution 2:

Apparently it was unnexpectedly easy to fix this issue. All you need to is to get to the <YourPath>\Python39\tcl directory and find tkdnd2.8 directory, and move it to the tcl8.6 directory. I have also renamed it to just tkdnd, however I don't know whether it's necessary.

Here is the original link that saved my day: http://pyinstaller.47505.x6.nabble.com/tkinter-TclError-can-t-find-package-tkdnd-td2330.html

Post a Comment for "*.py Script With Tkinterdnd2 Module Doesn`t Compile To An Executable File"