急救:linux redhat下python3.4如何安装tkinter

lgstudyvc 2015-06-25 10:45:10

linux下怎么安装tkinter??linux redhat下python3.4如何安装tkinter
导入时说没有
yum -y install tkinter也不正确,如图,请教大神如何,有说版本不匹配,没找到python3对应的tkinter啊


...全文
1121 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
lgstudyvc 2015-08-07
  • 打赏
  • 举报
回复
panghuhu250 2015-07-03
  • 打赏
  • 举报
回复
你的三个版本的python都是装在/usr/local/(一般是用户自己编译,安装的软件包),而yum.py是在/usr/lib是系统安装的。两个不统一。python2.6的系统路径不包括/usr/lib/python...,所以它找不到yum. 一个办法是下载,并用rpm安装系统的python2.6 rpm。另一个办法是在/usr/local下的python2.6中安装sos(https://github.com/sosreport/sos)。推荐第一个办法。 既然python2.6关系到系统的根本功能(yum),不知道为什么允许你把它卸载掉。
lgstudyvc 2015-07-01
  • 打赏
  • 举报
回复
三个版本的python使用的模块都是不同的,一个版本安装的模块另一个版本不能用。 已经知道2.4和3都不对了,yum估计是安装到python2.6的系统中了。把yum开头的python换成2.6的试试。 可以用
locate yum.py
locate yum/__init__.py
来确定yum模块的位置。 [/url][/quote] 你说的对,应该是2.6;可是yum该为2.6了,安装Tkinter还是下面问题 [root@localhost /]# vi /usr/bin/yum [root@localhost /]# python2.6 Python 2.6 (r26:66714, Jun 29 2015, 11:52:27) [GCC 4.4.4 20100726 (Red Hat 4.4.4-13)] 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 "/user/local/python2.6/lib/python2.6/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 >>> [root@localhost /]# yum -y install Tkinter 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.6 (r26:66714, Jun 29 2015, 11:52:27) [GCC 4.4.4 20100726 (Red Hat 4.4.4-13)] If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq [root@localhost /]# locate yum.py /usr/lib/python2.6/site-packages/sos/plugins/yum.py /usr/lib/python2.6/site-packages/sos/plugins/yum.pyc /usr/lib/python2.6/site-packages/sos/plugins/yum.pyo [root@localhost /]# locat yum/__init__.py -bash: locat: command not found [root@localhost /]#
panghuhu250 2015-06-29
  • 打赏
  • 举报
回复
引用 5 楼 lgstudyvc 的回复:
已经安装了python2.4,yum也指定了2.4 安装Tkinter时提示如下图 [root@localhost /]# yum -y install Tkinter 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 ... [root@localhost /]# ll /usr/bin/python* lrwxrwxrwx. 1 root root 34 6月 29 16:41 /usr/bin/python2.4 -> /usr/local/python2.4/bin/python2.4 lrwxrwxrwx. 1 root root 35 6月 29 14:25 /usr/bin/python2.6 -> /user/local/python2.6/bin/python2.6 lrwxrwxrwx. 1 root root 22 6月 29 15:02 /usr/bin/python3 -> /usr/local/bin/python3 [root@localhost /]# ,
三个版本的python使用的模块都是不同的,一个版本安装的模块另一个版本不能用。 已经知道2.4和3都不对了,yum估计是安装到python2.6的系统中了。把yum开头的python换成2.6的试试。 可以用
locate yum.py
locate yum/__init__.py
来确定yum模块的位置。 ---------------------------------------------------------- 说错误, 说真正错误, 拷错误信息说真正错误, 贴代码, 贴完整代码, 用语法高亮贴完整代码.
lgstudyvc 2015-06-29
  • 打赏
  • 举报
回复
已经安装了python2.4,yum也指定了2.4 安装Tkinter时提示如下图 [root@localhost /]# yum -y install Tkinter 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.4 (#1, Jun 29 2015, 16:33:01) [GCC 4.4.4 20100726 (Red Hat 4.4.4-13)] If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq 3个版本 的python都安装了 [root@localhost /]# ll /usr/bin/python* lrwxrwxrwx. 1 root root 34 6月 29 16:41 /usr/bin/python2.4 -> /usr/local/python2.4/bin/python2.4 lrwxrwxrwx. 1 root root 35 6月 29 14:25 /usr/bin/python2.6 -> /user/local/python2.6/bin/python2.6 lrwxrwxrwx. 1 root root 22 6月 29 15:02 /usr/bin/python3 -> /usr/local/bin/python3 [root@localhost /]# ,
lgstudyvc 2015-06-26
  • 打赏
  • 举报
回复
引用 2 楼 panghuhu250 的回复:

except KeyboardInterrupt, e:
这是python2的语法, 看起来是用python3运行了, 所以有这样的问题. 你的系统有python2吗? "head -n /usr/bin/yum"的输出是什么? ---------------------------------------------------------- 说错误, 说真正错误, 拷错误信息说真正错误, 贴代码, 贴完整代码, 用语法高亮贴完整代码.
用你的命令显示: root@localhost /]# head -n /usr/bin/yum head: /usr/bin/yum: 无效的号码%s [root@localhost /]# 看我的yum文件如下,其中第一行是我改为3的 [root@localhost /]# more /usr/bin/yum #!/usr/local/bin/python3 import sys try: import yum except ImportError: print >> sys.stderr, """\ There was a problem importing one of the Python modules required to run yum. The error leading to this problem was: %s 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: %s If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq """ % (sys.exc_value, sys.version) sys.exit(1) sys.path.insert(0, '/usr/share/yum-cli') try: import yummain yummain.user_main(sys.argv[1:], exit_code=True) except KeyboardInterrupt, e: print >> sys.stderr, "\n\nExiting on user cancel." sys.exit(1) [root@localhost /]# 同时,环境: [root@localhost /]# python -bash: python: command not found [root@localhost /]# python2 -bash: python2: command not found [root@localhost /]# python2.6 -bash: python2.6: command not found [root@localhost /]# python3 Python 3.4.3 (default, Jun 24 2015, 16:17:46) [GCC 4.4.4 20100726 (Red Hat 4.4.4-13)] on linux Type "help", "copyright", "credits" or "license" for more information. >>>
panghuhu250 2015-06-26
  • 打赏
  • 举报
回复

except KeyboardInterrupt, e:
这是python2的语法, 看起来是用python3运行了, 所以有这样的问题. 你的系统有python2吗? "head -n /usr/bin/yum"的输出是什么? ---------------------------------------------------------- 说错误, 说真正错误, 拷错误信息说真正错误, 贴代码, 贴完整代码, 用语法高亮贴完整代码.
panghuhu250 2015-06-26
  • 打赏
  • 举报
回复
对不起, 是"head -n 5 /usr/bin/yum", 显示文件的头5行. 你系统的yum是用python 2的, 所以你需要一个python2.x. 1.
ls -l /usr/bin/python*
如果有python2.x, (很可能是python2.7), 把yum开头的python改为相应的版本即可. 2. 如果没有python2.x, 那么需要安装python2.x, 但这时yum不能用了, 你得自己编译安装(或者通过rpm? 不知道redhat是否还支持rpm). 安装好后, 把yum开头的python指向新安装的python2. yum可以使用后, 建议你再用yum安装python2, 把自己安装的去掉. 最好让系统管理这些系统必需的包. ---------------------------------------------------------- 说错误, 说真正错误, 拷错误信息说真正错误, 贴代码, 贴完整代码, 用语法高亮贴完整代码.
lgstudyvc 2015-06-25
  • 打赏
  • 举报
回复
上传不了图片,操作如下:
[root@localhost /]#
[root@localhost /]# python3
Python 3.4.3 (default, Jun 24 2015, 16:17:46)
[GCC 4.4.4 20100726 (Red Hat 4.4.4-13)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/tkinter/__init__.py", line 38, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'
>>>
[root@localhost /]# yum -y install tkinter
File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
[root@localhost /]#

37,721

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧