ModuleNotFoundError:python 3.8.0 mac OS 10.15.3 上没有名为“_tkinter”的模块

doc*_*pus 8 python tkinter

在 Mac OS 10.15.3 (Catalina) 上使用 Python 3.8.0 和 pyenv。

当我尝试运行文件时,它返回:

ModuleNotFoundError: No module named '_tkinter'
Run Code Online (Sandbox Code Playgroud)

我试过了brew install tcl-tk。我有点担心,因为我在 pyenv 之上运行 python,任何第三方 tkinter 模块都无法正常运行。

运行brew doctor返回:

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
  `/Users/jm/.pyenv/shims/python3.7-config
  /Users/jm/.pyenv/shims/python3.7m-config
  /Users/jm/.pyenv/shims/python-config
  /Users/jm/.pyenv/shims/python3-config
  /Users/jm/.pyenv/shims/python3.8-config`
Run Code Online (Sandbox Code Playgroud)

sub*_*ker 6

在尝试了很多事情之后,这就是它最终工作的方式:

$ brew install python-tk
Run Code Online (Sandbox Code Playgroud)


小智 -1

你应该安装tkinter. 要安装,tkinter请在控制台上写入:

pip install tk
Run Code Online (Sandbox Code Playgroud)