【发布时间】:2020-01-19 03:46:55
【问题描述】:
我正在尝试使用 Tkinter 作为 GUI 将我的脚本捆绑到一个 .app 中,而进行捆绑的包装器是 Platypus。
我在运行应用程序时遇到此错误。
Traceback (most recent call last):
File "/Users/samb/Desktop/Beta1.app/Contents/Resources/script", line 4, in <module>
import tkinter
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/P...ework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
我在这台机器上运行 Python 3.7.4,我的脚本使用:
import tkinter
from tkinter import filedialog
这应该使它兼容。该脚本在我使用终端运行时有效,但在我运行应用程序时无效。
我在捆绑应用程序中指定它也应该使用 python3...
不确定我在这里做错了什么?
【问题讨论】:
-
我才刚刚开始使用 tkinter,但我认为它是 Python 附带的?编辑:当我输入 python3 和脚本的文件路径时,它似乎在终端中运行 - 这是否确认 tkinter 已正确安装在 python3 中?
-
你不必使用
import _tkinter,阅读Import _tkinter or tkinter? -
我的脚本没有使用
import _tkinter,也许包装器是?