I am currently working on MacOs Catalina 10.15.6 with Python 3.8 and Tcl/Tk 8.6. As suggested in here, I donwloaded both the Tk extension tkdnd2.8 from https://sourceforge.net/projects/tkdnd/ and the Python wrapper TkinterDnD2 from https://sourceforge.net/projects/tkinterdnd/, and then I copied the tkdnd2.8 directory to /Library/Tcl and the TkinterDnD2 directory to /Library/Frameworks/Python.framework/Versions/.../lib/python/site-packages.
After that, when trying to execute the following simple code:
from TkinterDnD2 import *
import tkinter as tk
root = TkinterDnD.Tk()
It gives me the error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/TkinterDnD2/TkinterDnD.py", line 39, in _require
TkdndVersion = tkroot.tk.call('package', 'require', 'tkdnd')
_tkinter.TclError: can't find package tkdnd
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Administrador/Desktop/tkdnd_test.py", line 3, in <module>
root = TkinterDnD.Tk()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/TkinterDnD2/TkinterDnD.py", line 271, in __init__
self.TkdndVersion = _require(self)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/TkinterDnD2/TkinterDnD.py", line 41, in _require
raise RuntimeError('Unable to load tkdnd library.')
RuntimeError: Unable to load tkdnd library.
Since tkdnd was not automatically being found/loaded (renaming the tkdnd2.8 folder to tkdnd didn't work either), I tried to manually specify the library path as suggested by @Ellis Shen and @aong152. I copied the tkdnd2.8 folder next to my tkdnd_test.py file. Unfortunately, when running the following code:
from TkinterDnD2 import *
import tkinter as tk
import sys, os
print(os.environ.get('TKDND_LIBRARY'))
application_path = os.path.dirname(os.path.abspath(__file__))
TK_DND_PATH = os.path.join(application_path,'tkdnd2.8')
os.environ['TKDND_LIBRARY'] = TK_DND_PATH
print(os.environ.get('TKDND_LIBRARY'))
root = TkinterDnD.Tk()
The same error is displayed (before that, the tkdnd path is printed):
None
/Users/Administrador/Desktop/tkdnd2.8
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/TkinterDnD2/TkinterDnD.py", line 39, in _require
TkdndVersion = tkroot.tk.call('package', 'require', 'tkdnd')
_tkinter.TclError: can't find package tkdnd
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Administrador/Desktop/tkdnd_test.py", line 11, in <module>
root = TkinterDnD.Tk()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/TkinterDnD2/TkinterDnD.py", line 271, in __init__
self.TkdndVersion = _require(self)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/TkinterDnD2/TkinterDnD.py", line 41, in _require
raise RuntimeError('Unable to load tkdnd library.')
RuntimeError: Unable to load tkdnd library.
I feel like I am missing something here, but I've spent a lot of time searching similar experiences and haven't been able to find a solution. Any help will be much appreciated.