1. 程式人生 > >centos升級python導致yum無法使用

centos升級python導致yum無法使用

    centos6升級了python的版本,導致yum執行出現No module named yum,而無法使用 原因:     跟yum匹配的python版本是系統帶的2.6版本,而現在python版本被更新到2.7     其他用到python的軟體也可能會出現這種問題,處理方法一樣:如下解決方法  現象: [[email protected] ~]# yum install http-devel -y 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.12 (default, Jan 10 2017, 10:36:02) [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] If you cannot solve this problem yourself, please go to the yum faq at:   http://yum.baseurl.org/wiki/Faq 解決辦法:
    檢查之前的版本python2.6是否存在:         [[email protected] ~]# ll /usr/bin/python*         lrwxrwxrwx  1 root root   24 Jan 10 10:36 /usr/bin/python -> /usr/local/bin/python2.7         lrwxrwxrwx. 1 root root    6 Aug 25 21:29 /usr/bin/python2 -> python         -rwxr-xr-x  1 root root 9032 Jul 24  2015 /usr/bin/python2.6     修改yum啟動指令碼:         vim /usr/bin/yum         把第一行的#!/usr/bin/python         修改為:             #!/usr/bin/python2.6    檢查是否可以使用:        [
[email protected]
~]# yum list        Loaded plugins: fastestmirror, security        Loading mirror speeds from cached hostfile 另外一種方法,網上找的,未測試,供參考:         首先找到你安裝Centos的光碟或者ISO檔案,拷貝如下檔案到系統中:        (或者找一個yum源,下載以下包也可以,只要系統版本一樣即可,例如:http://mirrors.ustc.edu.cn/centos/)
  python-2.6.6-36.el6.x86_64.rpm
  python-urlgrabber-3.9.1-8.el6.noarch.rpm
  python-devel-2.6.6-36.el6.x86_64.rpm
  python-libs-2.6.6-36.el6.x86_64.rpm
  yum-3.2.29-40.el6.centos.noarch.rpm
  具體版本號,根據你係統盤或者ISO提供為準。我是拷貝到了如下目錄
  /usr/local/rpm/Python-2.6.6
  執行安裝
  cd /usr/local/rpm/Python-2.6.6/
  rpm -Uvh --replacepkgs *.rpm