【发布时间】: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 上。
【问题讨论】:
-
如果你运行
sudo apt-get install python3.7-tk会发生什么? (取自stackoverflow.com/a/18143036/1248974) -
修复了它。谢谢
标签: python-3.x ubuntu tkinter pip python-3.7