Tkinter:“可能没有为Tk配置Python”

今天我想开始与Tkinter合作,但我遇到了一些问题。


Python 3.2 (r32:88445, Mar 28 2011, 04:14:07) 

[GCC 4.4.5] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> from tkinter import *

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

File "/usr/local/lib/python3.2/tkinter/__init__.py", line 39, in <module>

import _tkinter # If this fails your Python may not be configured for Tk

ImportError: No module named _tkinter

那么如何配置我的Python 3.2以使用Tkinter?


qq_笑_17
浏览 975回答 4
4回答

长风秋雁

在Arch / Manjaro下只需安装包tk:sudo pacman -S tk

智慧大石

tk-devel在构建Python之前安装(或类似命名的包)。

四季花海

为了pyenv在Ubuntu 16.04上使用它,我不得不:$ sudo apt-get install python-tk python3-tk tk-dev然后安装我想要的Python版本:$ pyenv install 3.6.2然后我可以很好地导入tkinter:import tkinter
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python