您的位置:首页 > 运维架构 > Linux

Linux下使用Python的Tkinter库出现的No module named _tkinter问题

2011-10-13 10:59 866 查看
在Linux下使用Tkinter库,出现如下问题

File "/usr/local/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>

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

ImportError: No module named _tkinter

Python的版本信息如下:

>>> import sys

>>> sys.version

'2.7 (r27:82500, Oct 11 2011, 13:51:21) \n[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)]'

经过艰苦绝伦的Google,查明问题出现原因,Tk/Tcl的组件安装不完全

问题解决:

下载Tk和Tcl,从www.scriptics.com上的链接下载tcl和tk的安装文件

现在最新的版本是8.4.4

http://prdownloads.sourceforge.net/tcl/tcl8.4.4-src.tar.gz

http://prdownloads.sourceforge.net/tcl/tk8.4.4-src.tar.gz

安装:

tar -zvxf tcl8.4.4.tar.gz

cd tcl8.4..4/

cd unix

./configure

make

make install

此时键入命令tclsh84,就可以使用tcl了

step3 安装tk与安装tcl类似

tar -zvxf tk8.4.4.tar.gz

cd tk8.4.4/

cd unix

./configure

make

make install

执行wish84就可以使用tk了。

注:安装tcl和tk的时候,make install 需要管理员的权限

安装完成了,重新make Python,然后,Tkinter库可以正常调用了

>>> from Tkinter import *

>>>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: