本文介绍了未为 Tk 配置 Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 pyenv 使用 Ubuntu 13.10 和 Python 3.3.4.我使用其他模块没有问题.当我进入python控制台并写入

I am using Ubuntu 13.10 and Python 3.3.4 using pyenv. I have no problem using other modules. When I enter python console and write

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-tktk-devel.

I already installed python3-tk and tk-devel.

推荐答案

您需要在 pyenv install 期间提供 Tk 开发文件/头文件.

You need to have the Tk development files/headers available during pyenv install.

在 Ubuntu (15.04) 上,应提供以下内容:sudo apt-get install tk-dev.

On Ubuntu (15.04) the following should provide them: sudo apt-get install tk-dev.

在此之后,pyenv install 3.4.3(或pyenv install 2.7.10 等)应该选择它并支持 Tk.

After this, pyenv install 3.4.3 (or pyenv install 2.7.10 etc) should pick it up and have support for Tk.

(pyenv 中的参考问题)

这篇关于未为 Tk 配置 Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 16:24
查看更多