Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find package tkdnd #424

Closed
AlbertLord opened this issue Aug 31, 2023 · 3 comments
Closed

Can't find package tkdnd #424

AlbertLord opened this issue Aug 31, 2023 · 3 comments

Comments

@AlbertLord
Copy link

Before posting I've reviewed issues: #104 and #225

I've made an application using the tkinter and tkinterdnd:

import tkinter as tk
from tkinter import filedialog
from tkinter import ttk
from tkinterdnd2 import DND_FILES, TkinterDnD

Using the PyInstaller code generated by auto-py-to-exe:
pyinstaller --noconfirm --onefile --windowed "E:/[REDACTED FOR PRIVACY]/stp_to_xyz_application.py"

Though the .exe was created successfully, running it gave an error message:

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 "stp_to_xyz_application.py", line 148, in
File "tkinterdnd2\TkinterDnD.py", line 285, in init
File "tkinterdnd2\TkinterDnD.py", line 55, in _require
RuntimeError: Unable to load tkdnd library.

After this I tried using the --hidden-import adding tkdnd and tkinterdnd2 to the command:
pyinstaller --noconfirm --onefile --windowed --hidden-import "tkinterdnd2" --hidden-import "tkdnd" "E:/[REDACTED]/stp_to_xyz_application.py"
This resulted in the same error.

Next I've added the paths of the library to the --paths :
pyinstaller --noconfirm --onefile --windowed --hidden-import "tkinterdnd2" --hidden-import "tkdnd" --paths "C:/Users/[REDACTED]/AppData/Local/Programs/Python/Python311/Lib/site-packages/tkdnd" --paths "C:/Users/[REDACTED]/AppData/Local/Programs/Python/Python311/Lib/site-packages/tkinterdnd2" "E:/[REDACTED]/stp_to_xyz_application.py"

Same error and I'm out of ideas.

Thank you for any help in advance.

@github-actions
Copy link

👋 Hi, just a reminder that if you haven't read the help post yet, give it a read to see if your issue is covered in it and make sure to follow the debugging section.

Also please note, as stated in the README, if your issue is only associated with your application and not auto-py-to-exe itself, please do not create an issue in this repository - instead, comment on the help post, video or create a new discussion.

@brentvollebregt
Copy link
Owner

Unfortunately this issue is library-specific so I won't be able to offer a huge amount of help as the issue more lies around how tkinterdnd2 works.

I see this comment is talking about a PyInstaller hook, which would have helped identify the missing parts - unfortunately that repo doesn't exist anymore. I just looked inside that module and saw there were a lot of .tcl files - maybe the library you are using also has these .tcl files?

I would recommend trying to add --collect-all MODULENAME - this should collect any data files from the package, like the potentially missing .tcl files.

@AlbertLord
Copy link
Author

Adding --collect-all tkinterdnd2 seem to resolve the problem.

Playing around a bit, I found that I do not need any --path or --hidden-import, the following command produced a working application:
pyinstaller --noconfirm --onefile --windowed --collect-all "tkinterdnd2" "E:/[REDACTED]/stp_to_xyz_application.py"

Thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants