今天将rhel6.4默认的python升级到了2.7,然后在使用yum的时候报如下错误:
-
[root@nortorm ~]# yum repolist
-
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.6 (default, Jan 3 2015, 14:09:58)
-
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)]
-
If you cannot solve this problem yourself, please go to
-
the yum faq at:
-
http://yum.baseurl.org/wiki/Faq
-
[root@nortorm ~]#
yum的wiki文档:
解决办法:
-
[root@nortorm bin]# pwd
-
/usr/bin
-
[root@nortorm bin]# ls python --将之前的2.6版本rename
-
python python2.6
-
[root@nortorm bin]# ls python
-
[root@nortorm bin]# vim /usr/bin/yum --修改环境为之前的版本
-
#!/usr/bin/python2.6
-
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:
-
-
""" % (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@nortorm bin]# yum repolist
-
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
-
Updating certificate-based repositories.
-
Unable to read consumer identity
-
repo id repo name status
-
epel Extra Packages for Enterprise Linux 6 - x86_64 11,199
-
repolist: 11,199
-
[root@nortorm bin]#
阅读(3096) | 评论(0) | 转发(0) |