解決centos6上python升級混亂導致yum報錯
轉自:http://www.linuxdiyf.com/linux/27055.html
親測方法二解決問題
由於伺服器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 [GCC 4.4.6 (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徹底崩了 最後找到補救方法,只有兩行程式碼。 方法二: