【问题标题】:ModuleNotFoundError: No module named '_tkinter' on python 3.8.0 mac OS 10.15.3ModuleNotFoundError:python 3.8.0 mac OS 10.15.3 上没有名为“_tkinter”的模块
【发布时间】:2020-05-25 09:35:54
【问题描述】:

在带有 pyenv 的 Mac OS 10.15.3 (Catalina) 上使用 Python 3.8.0。

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

ModuleNotFoundError: No module named '_tkinter'

我试过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`

【问题讨论】:

  • brew doctorbrew upgrade python3 命令显示什么?
  • 如果配置脚本覆盖了系统或 Homebrew 提供的同名脚本,则路径中的其他脚本可能会混淆通过 Homebrew 安装的软件。我们发现了以下“配置”脚本:/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-configbrew upgrade python3 返回了 Warning: python3 3.7.6_1 already installed
  • 尝试删除 python3.7 配置。看到这个issue
  • 它会影响我的 pyenv 设置吗?

标签: python tkinter


【解决方案1】:

在尝试了一堆东西之后,这就是它的最终效果:

$ brew install python-tk

【讨论】:

    【解决方案2】:

    尝试使用 pip3 它在我的 pip3 install tk 中工作

    【讨论】:

    • 在使用 Python 时,有许多库管理系统,例如 pip。我的建议是只使用其中一个。我还推荐 Anaconda Navigator,它会自动完成所有这些工作。
    【解决方案3】:

    您应该安装tkinter。要安装 tkinter 在控制台上写这个:

    pip install tk
    

    【讨论】:

      猜你喜欢
      • 2021-10-03
      • 1970-01-01
      • 2020-01-19
      • 2017-10-29
      • 1970-01-01
      • 1970-01-01
      • 2020-10-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多