当 运行 python 3.9.4 我无法导入 tkinter,但降级到 3.8.2 工作得很好

When running python 3.9.4 I am unable to import tkinter, but downgrading to 3.8.2 works perfectly fine

我在 macOS Catalina 运行 tcl 8.6.11 上,我安装 python3 使用 brew install python3

tclsh
% info patchlevel
8.6.11

当前版本 python 3.9.4

python3 --version 
Python 3.9.4 

>>> import tkinter 
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'

降级到 3.8.2

python3 --version 
Python 3.8.2

>>> import tkinter
>>> 

不确定是什么原因造成的,如有任何见解,我们将不胜感激

看起来 tkinter 在 python 3.9 的 brew 中被禁用了,但在 3.8 中没有,
it's commented on their github.

如果要使用 python 3.9.

,请尝试 python-tk 公式