升级Python导致yum报错
2015-09-16 16:44
597 查看
一天,需要在Linux服务器上面安装一个rpm包,结果运行yum命令的时候无论如何都会报错,如下:
[root@test bin]# 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.10 (default, Sep 7 2015, 10:39:35) [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[/code]报错信息中提到:It's possible that the above module doesn't match the current version of Python, which is: 2.7.10 (default, Sep 7 2015, 10:39:35)所以怀疑和刚刚升级的Python有关系,但是也不能为了yum将刚刚升级的Python协助了啊,
我们进一步查看:[root@test bin]# strace yum我们通过strace命令,发现日志中的下半部分,都是Python导致的错误,
execve("/usr/bin/yum", ["yum"], [/* 30 vars */]) = 0
brk(0) = 0x1849000
........
stat("/usr/bin", {st_mode=S_IFDIR|0555, st_size=40960, ...}) = 0
stat("/usr/bin/yum", {st_mode=S_IFREG|0755, st_size=801, ...}) = 0
open("/usr/bin/yum.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/bin/yummodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/bin/yum.py", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/bin/yum.pyc", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib/python2.7/yum", 0x7fff5cca59c0) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/python2.7/yum.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/python2.7/yummodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/python2.7/yum.py", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/python2.7/yum.pyc", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib/python2.7/plat-linux2/yum", 0x7fff5cca59c0) = -1 ENOENT (No such file or directory)
.....
write(2, "There was a problem importing on"..., 527There 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.10 (default, Sep 7 2015, 10:39:35)
[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
) = 527
write(2, "\n", 1
) = 1
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x343800f500}, {0x4e4a30, [], SA_RESTORER, 0x343800f500}, 8) = 0
brk(0x1907000) = 0x1907000
exit_group(1) = ?
[root@test bin]#
然后想起原来系统中的Python是 2.66版本的,后来我将其升级成了2.7.10了
会不会就是这个问题导致的呢? 然后我从其他的服务器(同版本)中下载下来一个2.66的Python,放到/usr/bin目录下,并且重命名为 python2.6
然后执行命令查找yum的位置,并且vi打开yum文件,将第一行的Python改为 python2.6
将其他yum开头的几个脚本也都做修改[root@test bin]# which yum /usr/bin/yum [root@test bin]# vi yum [root@test bin]# head -n 1 yum* ==> yum <== #!/usr/bin/python2.6 ==> yum-builddep <== #!/usr/bin/python2.6 -tt ==> yum-config-manager <== #!/usr/bin/python2.6 -tt ==> yum-debug-dump <== #!/usr/bin/python2.6 -tt ==> yum-debug-restore <== #!/usr/bin/python2.6 -tt ==> yumdownloader <== #!/usr/bin/python2.6 ==> yum-groups-manager <== #!/usr/bin/python2.6 -tt
再次运行yum命令,问题解决!
相关文章推荐
- python pexpect 启动、与子进程交互的例子--logstash
- Myeclipse + Python2.7.9,搭建Python开发环境
- Python改回之前版本的方法
- python:PyInstaller打包发布单个文件错误struct.error: argument for 's' must be a string解决
- 浅析python 中__name__ = '__main__' 的作用
- python知识点总结
- python上机题:黑色星期五
- JAVA读写Python脚本
- python指定时间运行函数
- python数值工厂函数和功能函数
- [python] 0x5 Python Tutorial: Web Requests
- python torndb模块
- python守护进程编写
- [python] 0x4 Python Tutorial: Python to EXE
- python 类属性 实例属性 类方法 实例方法 静态方法(转载)
- python日积月累之maketrans
- 使用python迭代器生成斐波那契数列
- python 多进程实现ssh
- python日积月累之lower()
- python日积月累之ljust()