Py2App找不到可用的tk.tcl

时间:2017-07-05 09:03:03

标签: python tkinter py2app

我正在尝试使用Tkinter GUI创建一个带有py2app的OS X Python 3应用程序。我已经在我的机器上将Python升级到v3.6.0并安装了正确版本的ActiveTcl(v8.5.18.0)。我可以开发和运行应用程序,我可以创建别名构建并运行正常但是当我创建并尝试运行独立版本时,我收到一条错误消息,指出无法找到tk.tcl

我已经浏览过互联网,并在网上找到了其他缺失文件的旧版本,但我找不到任何可以解决我的问题的解决方案。我知道我的tk.tcl文件在哪里,但我不知道怎么告诉它在哪里寻找它,我不知道为什么它在非标准的地方。无论如何。

任何人都可以帮我吗?

以下完整错误消息:

Traceback (most recent call last):
  File "/Users/Ste/Documents/Programming/rf-library/src/test/dist/test.app/Contents/Resources/__boot__.py", line 81, in <module>
    _run()
  File "/Users/Ste/Documents/Programming/rf-library/src/test/dist/test.app/Contents/Resources/__boot__.py", line 66, in _run
    exec(compile(source, path, 'exec'), globals(), globals())
  File "/Users/Ste/Documents/Programming/rf-library/src/test/dist/test.app/Contents/Resources/test.py", line 10, in <module>
    gui = tk.Tk()
  File "tkinter/__init__.pyc", line 2017, in __init__
_tkinter.TclError: Can't find a usable tk.tcl in the following directories: 

/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/tk8.5
/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/tk8.5/Resources/Scripts
/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/tk8.5
/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/tk8.5/Resources/Scripts
/Users/Ste/Documents/Programming/rf-library/src/test/dist/test.app/Contents/lib/tk8.5
/Users/Ste/Documents/Programming/rf-library/src/test/dist/test.app/Contents/lib/tk8.5/Resources/Scripts
~/Library/Tcl/tk8.5 ~/Library/Tcl/tk8.5/Resources/Scripts /Library/Tcl/tk8.5
/Library/Tcl/tk8.5/Resources/Scripts
/System/Library/Tcl/tk8.5
/System/Library/Tcl/tk8.5/Resources/Scripts
~/Library/Frameworks/tk8.5
~/Library/Frameworks/tk8.5/Resources/Scripts
/Library/Frameworks/tk8.5
/Library/Frameworks/tk8.5/Resources/Scripts
/System/Library/Frameworks/tk8.5
/System/Library/Frameworks/tk8.5/Resources/Scripts
/Users/Ste/Documents/Programming/rf-library/src/test/dist/test.app/lib/tk8.5
/Users/Ste/Documents/Programming/rf-library/src/test/dist/test.app/Contents/library



This probably means that tk wasn't installed properly.

called Tcl_CreateHashEntry on deleted table
Abort trap: 6

1 个答案:

答案 0 :(得分:0)

您使用的是哪个版本的py2app?我遇到了同样的问题,但是我可以通过降级为py2app 0.11来解决。我正在使用Python 3.5.2(这里分布在https://www.python.org/download/releases/3.5.2/上)和ActiveTcl 8.5.18.0https://www.activestate.com/activetcl/downloads)上。它像一种魅力。

如果您使用pip,只需在终端中执行以下操作:

$ pip3 uninstall py2app
$ pip3 install py2app==0.11

仅供参考,我最近升级了我的Python版本和许多功能(包括py2app)。我觉得Python是元凶。所以我尝试了Python 3.7.0、3.6.6和3.5.4。一直以来,我一直在使用py2app 0.12,而没有想到问题可能是py2app。我还多次卸载并重新安装了ActiveTcl 8.5.18,并且可以确认这不是问题。