带有 tkinterdnd2 模块的 *.py 脚本不会编译为可执行文件 [英] *.py script with tkinterdnd2 module doesn`t compile to an executable file

查看:98
本文介绍了带有 tkinterdnd2 模块的 *.py 脚本不会编译为可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个使用 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!

我尝试了以下操作:

  1. 使用 pip install 安装 tkinterdnd2,并使用 pyinstaller myscript.py 构建.
  2. 手动安装 tkinterdnd2 模块,如本视频所示 https://www.youtube.com/watch?v=JIy0QjwQBl0&t=605s&ab_channel=RamonWilliams 并使用 pyinstaller myscript.py
  3. 构建
  4. 重复上一步,但添加了这个东西https://github.com/pmgagne/tkinterdnd2/blob/master/hook-tkinterdnd2.py
  5. 试图通过使用 --paths 标志指定模块的路径来隐式地告诉 pyinstaller tkdnd 模块的路径.
  1. Installed tkinterdnd2 with pip install and built with pyinstaller myscript.py.
  2. 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
  3. Repeated previous step, but added this thing https://github.com/pmgagne/tkinterdnd2/blob/master/hook-tkinterdnd2.py
  4. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆