Chinaunix首页 | 论坛 | 博客
  • 博客访问: 48321
  • 博文数量: 12
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 70
  • 用 户 组: 普通用户
  • 注册时间: 2014-07-25 14:40
文章分类

全部博文(12)

文章存档

2015年(4)

2014年(8)

我的朋友

分类: Python/Ruby

2015-01-08 03:17:02

    今天将rhel6.4默认的python升级到了2.7,然后在使用yum的时候报如下错误:

点击(此处)折叠或打开

  1. [root@nortorm ~]# yum repolist
  2.     There was a problem importing one of the Python modules
  3.     required to run yum. The error leading to this problem was:
  4.     No module named yum
  5.     Please install a package which provides this module, or
  6.     verify that the module is installed correctly.
  7.     It's possible that the above module doesn't match the
  8.     current version of Python, which is:
  9.     2.7.6 (default, Jan 3 2015, 14:09:58)
  10.     [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)]
  11.     If you cannot solve this problem yourself, please go to
  12.     the yum faq at:
  13.     http://yum.baseurl.org/wiki/Faq
  14. [root@nortorm ~]#

yum的wiki文档:
解决办法:

点击(此处)折叠或打开

  1. [root@nortorm bin]# pwd
  2. /usr/bin
  3. [root@nortorm bin]# ls python --将之前的2.6版本rename
  4. python python2.6
  5. [root@nortorm bin]# ls python
  6. [root@nortorm bin]# vim /usr/bin/yum --修改环境为之前的版本
  7. #!/usr/bin/python2.6
  8. import sys
  9. try:
  10. import yum
  11. except ImportError:
  12. print >> sys.stderr, """\
  13. There was a problem importing one of the Python modules
  14. required to run yum. The error leading to this problem was:
  15. %s
  16. Please install a package which provides this module, or
  17. verify that the module is installed correctly.
  18. It's possible that the above module doesn't match the
  19. current version of Python, which is:
  20. %s
  21. If you cannot solve this problem yourself, please go to
  22. the yum faq at:

  23. """ % (sys.exc_value, sys.version)
  24. sys.exit(1)
  25. sys.path.insert(0, '/usr/share/yum-cli')
  26. try:
  27. import yummain
  28. yummain.user_main(sys.argv[1:], exit_code=True)
  29. except KeyboardInterrupt, e:
  30. print >> sys.stderr, "\n\nExiting on user cancel."
  31. sys.exit(1)

恢复正常:

点击(此处)折叠或打开

  1. [root@nortorm bin]# yum repolist
  2. Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
  3. Updating certificate-based repositories.
  4. Unable to read consumer identity
  5. repo id repo name status
  6. epel Extra Packages for Enterprise Linux 6 - x86_64 11,199
  7. repolist: 11,199
  8. [root@nortorm bin]#



  


阅读(3013) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~