0°

CentOS Linux 7.6.1810 误删除yum和python该如何恢复?

今日,博主为了想把python版本升级到3.8版本,升级后发现许多组件要做软链接,太过于麻烦,而2.7版本在2020年又要失去支持了,本来高高兴兴的,结果发现宝塔面板也是基于python 2.7的,无奈之下,百度了很多降级方法,太过于麻烦,最后折腾了半天,有的都不是Centos 7.6版的,要找下载链接,如是乎,就有了以下操作。

第一步,删除python及yum相关文件

pm -qa|grep python|xargs rpm -ev --allmatches --nodeps

实际测试时这一步就够了,如果还不放心,再把yum卸载一遍。

rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps
rm -rf /etc/yum.repos.d/*

作为逻辑的一环,当然是要检测下还有没有残留:

whereis python|xargs rm -fr
whereis yum|xargs rm -fr

一般都是无返回结果,毕竟都已经强制卸载了,如果有就是再重复删除一遍。

第二步,就是重新下载python及yum相关文件

这一步呢,我就把所有的下载链接整合起来了,应该就是以下这些:
含有python当然是python链接,有yum就是yum链接了.

wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/lvm2-python-libs-2.02.180-8.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/python-libs-2.7.5-76.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/python-ipaddress-1.0.16-2.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/python-backports-1.0-8.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/python-2.7.5-76.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/python-setuptools-0.9.8-7.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/python-chardet-2.2.1-1.el7_1.noarch.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/rpm-python-4.11.3-35.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/yum-utils-1.1.31-50.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/yum-plugin-aliases-1.1.31-50.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/yum-plugin-protectbase-1.1.31-50.el7.noarch.rpm

第三步,就是安装python及yum相关文件

切记:要分开分步执行的,尽量别复制一整段执行,很容易出问题。

rpm -Uvh --replacepkgs lvm2-python-libs*.rpm

rpm -Uvh --replacepkgs libxml2-python*.rpm

rpm -Uvh --replacepkgs python*.rpm

rpm -Uvh --replacepkgs rpm-python*.rpm yum*.rpm

第四步分别用python和yum list查看情况

这样整个的步骤就全部完成了!

「点点赞赏,手留余香」

    还没有人赞赏,快来当第一个赞赏的人吧!
0 条回复 A 作者 M 管理员
    所有的伟大,都源于一个勇敢的开始!
欢迎您,新朋友,感谢参与互动!欢迎您 {{author}},您在本站有{{commentsCount}}条评论