gpt4 book ai didi

python - 在 Ubuntu 上找不到 Tkinter 模块

转载 作者:行者123 更新时间:2023-12-03 05:17:25 27 4
gpt4 key购买 nike

Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
>>>

另一方面...

Python 3.2 (r32:88445, Mar 25 2011, 19:28:28) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Tkinter

我检查了 synaptic,Tkinter 已安装。然后我发现了这个--

If it fails with "No module named _tkinter", your Python configuration needs to be modified to include this module (which is an extension module implemented in C). Do not edit Modules/Setup (it is out of date). You may have to install Tcl and Tk (when using RPM, install the -devel RPMs as well) and/or edit the setup.py script to point to the right locations where Tcl/Tk is installed. If you install Tcl/Tk in the default locations, simply rerunning "make" should build the _tkinter extension.

我猜测 tkinter 仍然与我电脑中的旧 python 相关联。我如何更改它以便 python3 可以使用 tkinter?

最佳答案

在 Ubuntu 中对我有用的实际上只是:

sudo apt-get install python3-tk

对于 python 3.6:

sudo apt-get install python3.6-tk

我没有在任何地方阅读,我只是尝试了一下,因为onteria_的方法似乎不适合我。

关于python - 在 Ubuntu 上找不到 Tkinter 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6084416/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com