带有 tkinterdnd2 模块的 *.py 脚本不会编译为可执行文件 [英] *.py script with tkinterdnd2 module doesn`t compile to an executable file
问题描述
我制作了一个使用 tkinter 和 tkinterdnd 模块的应用程序.当我将它作为脚本启动时它完全正常,但是当我尝试从中创建可执行文件并启动它时,出现以下错误:
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, foloowing error ocures:
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 "IxcomGUI.py", line 128, in <module>
File "IxcomGUI.py", line 11, in __init__
File "TkinterDnD2\TkinterDnD.py", line 285, in __init__
File "TkinterDnD2\TkinterDnD.py", line 55, in _require
RuntimeError: Unable to load tkdnd library.
[14512] Failed to execute script 'IxcomGUI' due to unhandled exception!
我尝试了以下操作:
- 使用
pip install
安装 tkinterdnd2,并使用pyinstaller myscript.py
构建. - 手动安装 tkinterdnd2 模块,如本视频所示 https://www.youtube.com/watch?v=JIy0QjwQBl0&t=605s&ab_channel=RamonWilliams 并使用
pyinstaller myscript.py
构建 - 重复上一步,但添加了这个东西https://github.com/pmgagne/tkinterdnd2/blob/master/hook-tkinterdnd2.py
- 试图通过使用 --paths 标志指定模块的路径来隐式地告诉 pyinstaller tkdnd 模块的路径.
- Installed tkinterdnd2 with
pip install
and built withpyinstaller myscript.py
. - Manually installed tkinterdnd2 module as shown in this video https://www.youtube.com/watch?v=JIy0QjwQBl0&t=605s&ab_channel=RamonWilliams and built with
pyinstaller myscript.py
- Repeated previous step, but added this thing https://github.com/pmgagne/tkinterdnd2/blob/master/hook-tkinterdnd2.py
- Tried to implicitly tell pyinstaller path to tkdnd module with specifying path to the module with --paths flag.
所有这些尝试都导致了以下错误.有人知道某种解决方案吗?
All this attempts led to error bellow. Does anyone know some kind of solution?
推荐答案
显然,解决这个问题出乎意料地容易.您所需要做的就是进入<YourPath>\Python39\tcl
目录并找到tkdnd2.8
目录,并将其移动到tcl8.6
目录.我也把它重命名为tkdnd,但我不知道是否有必要.
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.
这是拯救我一天的原始链接:http://pyinstaller.47505.x6.nabble.com/tkinter-TclError-can-t-find-package-tkdnd-td2330.html
Here is the original link that saved my day: http://pyinstaller.47505.x6.nabble.com/tkinter-TclError-can-t-find-package-tkdnd-td2330.html
这篇关于带有 tkinterdnd2 模块的 *.py 脚本不会编译为可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!