【问题标题】:Python3-tk is already installed but python3.7 can't find module tkinterPython3-tk 已经安装,但是 python3.7 找不到模块 tkinter
【发布时间】:2019-10-04 07:09:28
【问题描述】:

我正在使用一些在后台运行 tensorflow 的 python3.7 代码。当我运行它时,我收到以下错误:

import tkinter as Tk
ModuleNotFoundError: No module named 'tkinter'

我做了一些谷歌搜索,发现我需要安装 python3-tk,所以我运行了以下命令:

sudo apt-get install python3-tk

并获得以下输出确认它已安装:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-tk is already the newest version (3.5.1-1).
0 upgraded, 0 newly installed, 0 to remove and 108 not upgraded.

然而,当我进入我的 python3.7 解释器并使用以下命令对其进行测试时

$python3.7
>> import tkinter

我得到以下输出说它没有安装:

$ python3.7
Python 3.7.3 (default, Mar 26 2019, 01:59:45) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tkinter'

当 apt 已经认为它已安装时,如何让 tkinter 在 python3.7 上运行?另一方面,我不在 Ubuntu 16 上。

【问题讨论】:

标签: python-3.x ubuntu tkinter pip python-3.7


【解决方案1】:

@davedwards 使用以下命令解决了这个问题:

sudo apt-get install python3.7-tk

【讨论】:

    猜你喜欢
    • 2020-11-14
    • 2020-12-04
    • 2021-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多