加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

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

(2013-09-13 09:42:52)
标签:

技术型文章

文化

分类: python

在Linux下使用Tkinter库,出现如下问题 

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

    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 *
>>>  

 

转自:http://blog.csdn.net/keyoflov/article/details/6869167

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有