Python升级提示Tkinter模块找不到的解决方法
一、安装tkinter
在Linux中python默认是不安装Tkinter模块,
复制代码 代码如下:
[root@li250-193 ~]# python
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Tkinter
>>>
我们安装Tkinter模块
复制代码 代码如下:
[root@li250-193 ~]# yum -y install tkinter
...
[root@li250-193 ~]# python
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
>>>
二、升级Python
Linux的Python版本默认都不叫低
查看Python版本
复制代码 代码如下:
[root@li250-193 ~]# python -V
Python 2.6.6
DOWN新版本
复制代码 代码如下:
[root@li250-193 ~]# wget http://www.python.org/ftp/python/2.7.4/Python-2.7.4.tgz
解压安装
复制代码 代码如下:
[root@li250-193 ~]# tar -xf Python-2.7.4.tgz
[root@li250-193 ~]# cd Python-2.7.4
[root@li250-193 Python-2.7.4]# ./configure
...
[root@li250-193 Python-2.7.4]# make
...
[root@li250-193 Python-2.7.4]# make install
...
看看新版本Python是否可以使用Tkinter?
复制代码 代码如下:
[root@li250-193 Python-2.7.4]# ./python
Python 2.7.4 (default, Apr 12 2013, 08:03:09)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/Python-2.7.4/Lib/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
>>>
提示找不到tkinter模块?看看旧版的是不是正常
复制代码 代码如下:
[root@li250-193 Python-2.7.4]# python
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
>>>
旧版的没问题,难道需要yum install tkinter一次?
复制代码 代码如下:
[root@li250-193 Python-2.7.4]# yum install tkinter
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirror.team-cymru.org
* extras: mirror.team-cymru.org
* updates: mirror.team-cymru.org
Setting up Install Process
Package tkinter-2.6.6-36.el6.x86_64 already installed and latest version
Nothing to do
提示已安装,看来不是tkinter的问题,看看tkinter模块在哪里?
复制代码 代码如下:
[root@li250-193 Python-2.7.4]# find /usr -name *tkinter.so
/usr/lib64/python2.6/lib-dynload/_tkinter.so
找到一个,在2.6旧版本的目录下,估计是因为新版本库指向问题。于是认真读了README说明。重新配置安装
三、正确安装新版Python
首先修改Setup.dist文件
复制代码 代码如下:
[root@li250-193 Python-2.7.4]# vim Modules/Setup.dist
找到下面这几行,把前面的井号去掉打开它
复制代码 代码如下:
_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \
-L/usr/local/lib \
-I/usr/local/include \
-ltk8.5 -ltcl8.5 \
-lX11
以上第四行
-ltk8.5 -ltcl8.5 默认是 8.2 ,请你系统实际tcl/tk版本修改
复制代码 代码如下:
[root@li250-193 Python-2.7.4]# rpm -qa | grep ^tk
tk-8.5.7-5.el6.x86_64
tkinter-2.6.6-36.el6.x86_64
[root@li250-193 Python-2.7.4]# rpm -qa | grep ^tcl
tcl-8.5.7-6.el6.x86_64
我系统中装的是8.5,所以这里我改成了8.5
保存退出
安装tck-devel、tk-devel
复制代码 代码如下:
[root@li250-193 Python-2.7.4]# yum -y install tcl-devel tk-devel
开始配置安装
复制代码 代码如下:
[root@li250-193 Python-2.7.4]# ldconfig
[root@li250-193 Python-2.7.4]# ./configure
...
[root@li250-193 Python-2.7.4]# make
...
[root@li250-193 Python-2.7.4]# make install
...
看下新版Python是否可以使用tkinter模块
复制代码 代码如下:
[root@li250-193 Python-2.7.4]# ./python
Python 2.7.4 (default, Apr 12 2013, 08:49:11)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
>>>
已经没问题,旧版再看看
复制代码 代码如下:
[root@li250-193 Python-2.7.4]# /usr/bin/python2.6
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
>>>
也没问题
如果直接敲入python -V查看版本是不是最新的,如果不是可以这么干:
which出python命令路径
复制代码 代码如下:
[root@li250-193 Python-2.7.4]# which python
/usr/local/bin/python
cp 过去
复制代码 代码如下:
[root@li250-193 Python-2.7.4]# cp python /usr/local/bin/python
四、升级Python引起yum版本无法使用的问题解决
不少童鞋安装后就
复制代码 代码如下:
cp python /usr/bin/python
导致yum时就提示
复制代码 代码如下:
[root@lee ~]# yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named yum
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python, which is:
2.7.4 (default, Apr 9 2013, 17:12:56)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
[root@lee ~]#
因为yum头部默认制定python脚本的路径就是
复制代码 代码如下:
#! /usr/bin/python
你把旧版的python替换后就是用不了,不知道为何新版Python不能被yum识别,目前唯一最好解决的方法就是修改yum头部声明
改成
复制代码 代码如下:
#! /usr/bin/python2.6
源文档 <http://www.jb51.net/article/54153.htm>
Python升级提示Tkinter模块找不到的解决方法的更多相关文章
- Linux升级Python提示Tkinter模块找不到解决
一.安装tkinter 在Linux中python默认是不安装Tkinter模块, [root@li250- ~]# python Python (r266:, Feb , ::) [GCC (Red ...
- python安装mysqlclient模块时报mysql_config not found解决方法
在配置Flask框架,安装mysqlclient时报一下错误 翻译了一下大概是 mysql_config 文件没找到, 解决方法是安装缺失的文件. sudo apt install libmysql ...
- python使用pip安装第三方模块遇到的问题及解决方法
python使用pip安装第三方模块遇到的问题及解决方法 关注公众号"轻松学编程"了解更多. 使用国内源: 清华:https://pypi.tuna.tsinghua.edu.cn ...
- 【转】在Python的struct模块中进行数据格式转换的方法
这篇文章主要介绍了在Python的struct模块中进行数据格式转换的方法,文中还给出了C语言和Python语言的数据类型比较,需要的朋友可以参考下 Python是一门非常简洁的语言,对于数据类型的表 ...
- win安装python模块出现依赖问题的解决方法 & No module named 'MySqldb'
前言 一年多了,还在写这种问题,羞愧. 新公司不让用自己的电脑,配的winPC,项目启不起来,之前也出现过这个问题,是py3缺少某个模块,但是自己没记,这次记一下好了. No module named ...
- http://localhost/certsrv 错误找不到页面解决方法
http://localhost/certsrv 错误找不到页面解决方法 最近公司需要后台启动安全证书,可安装了“Active Directory证书服务” 后,http://localhost/ce ...
- 【spring cloud】spring boot2.x下 使用feign,注解@EnableFeignClients 找不到的解决方法
spring boot2.x下 使用feign,注解@EnableFeignClients 找不到的解决方法 在spring boot1.x下,使用注解@EnableFeignClients,jar包 ...
- python学习笔记(9)--Python UnicodeEncodeError: 'gbk' codec can't encode character 解决方法
Python UnicodeEncodeError: 'gbk' codec can't encode character 解决方法 这篇文章主要介绍了Python UnicodeEncodeErro ...
- 【java】查看Java字节码文件内容的方法+使用javap找不到类 解决方法
研究synchronized底层实现,涉及到查看java字节码的需要 前提是,你的PC已经成功安装了JDK并别配置了环境变量. ==========查看方法========= 一.javap查看简约字 ...
随机推荐
- Vue 一些用法
v-model : 数据绑定(多数用于表单元素) ps:同时v-model支持双向数据绑定v-for : 用于元素遍历v-on:事件名称=“方法名” (事件绑定)ps: methods:用于绑定 v- ...
- iframe中的target属性
在使用iframe的时候,我们有时候会遇到,外面的链接,去操作iframe中的页面 <!DOCTYPE html> <html> <head> <meta c ...
- 数据库连接池,DBUtil的模板,dbcp,c3p0
数据库连接池,DBUtil的模板,Druid使用(重点) 一.DBUtil模板 public class DBUtilTest { public static Connection connectio ...
- C# 之 .net core -- MVC模式的显示、增、删、改
上一篇介绍数据的创建连接,接下来就是基本的增删改 一.右键添加.控制器 二.选择这个带试图的 三.其他的不要动,点击添加 四.执行一下,改下url 试一下他的增删改. 其实自己写的话可以用form表单 ...
- Python+request+ smtplib 测试结果html报告邮件发送(上)《五》
此方法通用适合所有邮箱的使用,只需注意几个点,如下: QQ邮箱.其他非QQ邮箱的写法,区别点如下: #--------------------------使用腾讯企业邮箱作为发件人的操作如下----- ...
- ubuntu redis 安装 &基本命令
参考资料:https://www.cnblogs.com/zongfa/p/7808807.htmlredis命令参考:http://doc.redisfans.com/安装:sudo apt-get ...
- SQL分表
一.为什么要水平分表?简而言之,当单表数据量过大时,无法对其进行有效的维护,以及查询速度严重变慢时,我们就需要对其时行水平分表. 二.什么时候需要水平分表?在数据库结构的设计中,需要充分考虑后期数据的 ...
- 2019EC-Final参赛总结
本来想发知乎上的,后来发现太长就放这好了23333 没写过这种东西,所以写得比较混乱&流水账 以下内容均为我的个人视角XD 赛前 在车上的时候,红太阳跟我们说他头晕(虽然他好像每场比赛都头 ...
- 题解 [APIO2014]连珠线
题解 [APIO2014]连珠线 题面 解析 首先这连成的是一棵树啊. 并且\(yy\)一下,如果钦定一个根, 那么这上面的蓝线都是爸爸->儿子->孙子这样的,因为像下图这样的构造不出来: ...
- window.open全屏显示
将window.open(url,'','height=600,width=910,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes,resizabl ...