標籤: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”錯誤