Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在macOsSierra上使用tkinter模块_Python_Macos_Tkinter - Fatal编程技术网

Python 如何在macOsSierra上使用tkinter模块

Python 如何在macOsSierra上使用tkinter模块,python,macos,tkinter,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 Could not find a version that satisfies the requi

我正在尝试学习如何在Python中使用tkinter模块,但当我在本地运行它时,会出现以下错误:

Traceback (most recent call last):
  File "emailer", line 1, in <module>
    from tkinter import messagebox
ImportError: No module named tkinter
Could not find a version that satisfies the requirement tkinter (from versions: )
No matching distribution found for tkinter
最后,在终端中运行
哪个python
时,输出是
/usr/bin/python

如果您是从Python.org使用Python 64位/32位Python Mac OS X 10.6及更高版本的安装程序,您应该只使用空闲或 tkinter具有更新的第三方Tcl/Tk 8.5(不是8.6),如 8.5已安装

如果您使用的是Mac OS X 10.6,请不要从中使用IDLE或Tkinter 苹果在MacOSX10.6中提供了Python 2.6.1。如果可能,请安装并安装 使用较新版本的Python和Tcl/Tk

如果您使用的是Mac OS X 10.7或更高版本,则苹果提供的Tcl/Tk 8.5 仍然存在可能导致应用程序崩溃的严重错误。如果你愿意 要使用IDLE或Tkinter,请安装并使用更新版本的Python和 Tcl/Tk的应用

实际上,您可以使用
自制

brew install tcl-tk

brew link tcl-tk --force
看一看