centos 上yum命令刪除補救方法
由於伺服器centos6.8安裝tensorflow,安裝python版本過多導致連結混亂,最終yum無法使用
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.9 (default, Mar 27 2015, 18:24:01)
[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
伺服器沒有yum幾乎就是殘廢的系統,無論如何yum都要補上
方法一:# python --version檢視python 版本
# whereis python 檢視python檔案
python: /usr/bin/python2.6 /usr/bin/python /usr/lib/python2.7 /usr/lib/python2.6 /usr/lib64/python2.7 /usr/lib64/python2.6 /usr/include/python2.7 /usr/share/man/man1/python.1.gz
centos6.8基本底層python是python2.6 centos7是2.7,我的是centos6.8
解決辦法
修改yum檔案
#vi /usr/bin/yum
將 #!/usr/bin/python 修改為 #!/usr/bin/python2.6
以上方法解決問題後,由於手賤又安裝了python2.7.5,python3.4.5 還相信網上所說改了bash/profile,最後出現
-bash: /usr/bin/yum: /usr/bin/python2.6: bad interpreter: No such file
很明顯連結混亂找不到python2.6連線了
又按照不靠譜的重灌yum方法,yum徹底崩了
最後找到補救方法,只有兩行程式碼
方法二:$ rpm -qa | grep python- | grep 2.6
$ sudo rpm -ivh --force --nodeps ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/6.5/x86_64/updates/fastbugs/python-2.6.6-52.el6.x86_64.rpm
解決問題,yum可以使用,原理估計是python回滾到預設的2.6
方法三 非常麻煩不建議使用
http://mirrors.163.com/centos/6/os/x86_64/Packages/
到上面這個網站去下載如下RPM包
python-iniparse-0.3.1-2.1.el6.noarch.rpm
yum-metadata-parser-1.1.2-14.1.el6.x86_64.rpm
yum-3.2.29-69.el6.centos.noarch.rpm
yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm
下載完成之後,用rpm命令進行安裝,如下:
rpm -ivh --force --nodeps python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh --force --nodeps yum-metadata-parser-1.1.2-14.1.el6.x86_64.rpm
rpm -ivh --force --nodeps yum-3.2.29-69.el6.centos.noarch.rpm yum-plugin-fa
stestmirror-1.1.30-30.el6.noarch.rpm
到 http://yum.baseurl.org/wiki
下載yum-3.4.3.tar.gz ,放到你指定的目錄下解壓,解壓命令如下:
tar -zxvf yum-3.4.3.tar.gz #解壓後進到yum-3.4.3目錄
#./yummain.py update
完成之後,輸入yum 解決問題
參考
http://blog.sina.com.cn/s/blog_4cbf97060100u2zb.html
http://blog.csdn.net/u011531010/article/details/53528054
http://blog.sina.com.cn/s/blog_643754960102w82m.html