Bry*_*anB 4 python macos tkinter
我正在尝试学习如何在 Python 中使用 tkinter 模块,但是当我在本地运行它时,我收到以下错误:
Traceback (most recent call last):
File "emailer", line 1, in <module>
from tkinter import messagebox
ImportError: No module named tkinter
Run Code Online (Sandbox Code Playgroud)
我试过了pip install tkinter,sudo pip install tkinter这会引发以下错误:
Could not find a version that satisfies the requirement tkinter (from versions: )
No matching distribution found for tkinter
Run Code Online (Sandbox Code Playgroud)
最后which python在终端中运行时,输出是/usr/bin/python
如果您在 Mac OS X 10.6 及更高版本的 python.org 64 位/32 位 Python 安装程序中使用 Python,则您应该只将 IDLE 或 tkinter 与更新的第三方 Tcl/Tk 8.5(而不是 8.6)一起使用,例如 已安装ActiveTcl 8.5。
如果您使用的是 Mac OS X 10.6,请勿在 Mac OS X 10.6 中使用 Apple 提供的 Python 2.6.1 中的 IDLE 或 Tkinter。如果可能,安装并使用更新版本的 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
Run Code Online (Sandbox Code Playgroud)
看看tcltk。
| 归档时间: |
|
| 查看次数: |
8633 次 |
| 最近记录: |