未为Tk配置Python
我正在使用 pyenv 使用Ubuntu 13.10和Python 3.3.4 。使用其他模块没有问题。当我进入python控制台并编写时
import tkinter
它输出
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/serdar/.pyenv/versions/3.3.4/lib/python3.3/tkinter/__init__.py", line 40, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'
我已经安装python3-tk
和tk-devel
。
-
您需要在期间提供Tk开发文件/头
pyenv install
。在Ubuntu(15.04)上,应提供以下内容:
sudo apt-get install tk-dev
。之后,
pyenv install 3.4.3
(或其他pyenv install 2.7.10
)应将其拿起并获得Tk的支持。