我正在尝试学习如何在 Python 中使用 tkinter 模块,但是当我在本地运行它时,出现以下错误:
Traceback (most recent call last):
File "emailer", line 1, in <module>
from tkinter import messagebox
ImportError: No module named tkinter
我试过了pip install tkinter
and sudo pip install tkinter
这会引发以下错误:
Could not find a version that satisfies the requirement tkinter (from versions: )
No matching distribution found for tkinter
最后在跑步时which python
在终端中的输出是/usr/bin/python
如果您使用来自 python.org 的 Python 64 位/32 位 Python
Mac OS X 10.6 及更高版本的安装程序,您应该只使用 IDLE 或
tkinter 具有更新的第三方 Tcl/Tk 8.5(不是 8.6),例如主动Tcl http://www.activestate.com/activetcl/downloads8.5安装。
如果您使用的是 Mac OS X 10.6,请勿使用 IDLE 或 Tkinter
Apple 在 Mac OS X 10.6 中提供了 Python 2.6.1。如果可能的话,安装并
使用较新版本的 Python 和 Tcl/Tk。
如果您使用的是 Mac OS X 10.7 或更高版本,Apple 提供的 Tcl/Tk 8.5
仍然存在可能导致应用程序崩溃的严重错误。如果你希望
要使用 IDLE 或 Tkinter,请安装并使用较新版本的 Python 并
Tcl/Tk 的。
其实你可以使用homebrew
:
brew install tcl-tk
brew link tcl-tk --force
看一下tcltk https://www.python.org/download/mac/tcltk/.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)