[Python] PyInstaller + tkdnd/tkinterdnd2 "Unable to load tkdnd library" when launching frozen...

Discussão em 'Python' iniciado por Stack, Dezembro 20, 2024.

  1. Stack

    Stack Membro Participativo

    In my script I am using tkinterdnd2 library to achieve drag and drop functionality from Windows explorer into my tkinter UI.

    from tkinterdnd2 import TkinterDnD, DND_FILES
    import tkinter as tk

    class TkWindow:
    def __init__(self):
    self.window = TkinterDnD.Tk()
    self.tbox = tk.Listbox(self.window)
    self.tbox.pack(fill=tk.BOTH)
    self.tbox.drop_target_register(DND_FILES)
    self.tbox.dnd_bind('<<Drop>>', self.tk_files_dropped)
    self.window.mainloop()

    def tk_files_dropped(self, event):
    messagebox.showinfo("x", event.data)

    TkWindow()


    When I launch the script - everything works.

    But when I freeze the project to a single EXE with PyInstaller, and run it, I get this error:

    [​IMG]

    I tried this solutions already:


    1. I added the pyinstaller-hook as instructed in the tkinterdnd2 repository:

      from PyInstaller.utils.hooks import collect_data_files, eval_statement
      datas = collect_data_files('tkinterdnd2')


    2. I add --collect-all tkinterdnd2 when executing build command.


    3. I tried copying tkdnd2.8 to tcl8.6 as mentioned in this answer


    4. I tried getting rid of venv and installing all the packages directly into base python interpreter.

    Continue reading...

Compartilhe esta Página