[linux]centos7 升級python後出現“No module named yum”錯誤

來源:互聯網
上載者:User

標籤:python   版本   evel   wiki   mirror   使用   des   ...   inux   

公司伺服器重新安裝系統後,手動升級python2.7.5到2.7.15,安裝完python在更新系統python版本的過程中無意刪除了系統內建的版本,導致後來在執行yum命令的時候出現了錯誤

There was a problem importing one of the Python modulesrequired to run yum. The error leading to this problem was:   No module named yumPlease install a package which provides this module, orverify that the module is installed correctly.It‘s possible that the above module doesn‘t match thecurrent version of Python, which is:2.7.15 (default, May 21 2018, 11:43:18)[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]If you cannot solve this problem yourself, please go tothe yum faq at:  http://yum.baseurl.org/wiki/Faq

考慮到原來系統使用的python版本為2.7.5,手動編譯安裝python2.7.5版本後還是出現該問題。

解決方案:

下載下列檔案:python-2.4.3-46.el5_8.2.i386.rpmpython-devel-2.4.3-46.el5_8.2.i386.rpmpython-libs-2.4.3-46.el5_8.2.i386.rpmpython-tools-2.4.3-46.el5_8.2.i386.rpmtix-8.4.0-11.fc6.i386.rpmtix-devel-8.4.0-11.fc6.i386.rpmtkinter-2.4.3-46.el5_8.2.i386.rpmyum-3.2.22-39.el5.centos.noarch.rpm:http://mirrors.163.com/centos/7/os/x86_64/Packages/[[email protected] x]# lspython-2.4.3-46.el5_8.2.i386.rpm tix-8.4.0-11.fc6.i386.rpmpython-devel-2.4.3-46.el5_8.2.i386.rpm tix-devel-8.4.0-11.fc6.i386.rpmpython-libs-2.4.3-46.el5_8.2.i386.rpm tkinter-2.4.3-46.el5_8.2.i386.rpmpython-tools-2.4.3-46.el5_8.2.i386.rpm yum-3.2.22-39.el5.centos.noarch.rpm[[email protected] x]# rpm -Uvh --replacepkgs *.rpmPreparing... ########################################### [100%]1:tix ########################################### [ 13%]2:tix-devel ########################################### [ 25%]3:python ########################################### [ 38%]4:tkinter ########################################### [ 50%]5:python-devel ########################################### [ 63%]6:python-libs ########################################### [ 75%]7:python-tools ########################################### [ 88%]8:yum ########################################### [100%][[email protected] x]# yum update

更新系統yum檔案

 

mv /bin/python2.7 /bin/python2.7.5

# 修改yum檔案引用的python版本
vim /usr/bin/yum
#!/bin/python2.7.5 <--- 修改為

 

 

 


[linux]centos7 升級python後出現“No module named yum”錯誤

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.