Centos8误删除python导致yum被损坏的恢复方案

Published on 2023-03-30 13:56 in 分类: 软件 with 狂盗一枝梅
分类: 软件

总体解决思路就是卸载和删除python、yum的残留文件,再下载自己系统版本对应的python、yum包进行安装。

一、彻底卸载python和yum

删除python已安装程序及其关联

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

删除残余python文件

whereis python |xargs rm -frv

验证删除,返回为无结果

whereis python

删除现有yum

rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps

删除残余yum文件

whereis yum |xargs rm -frv

二、下载安装包

创建目录python和yum用以存放rpm包

mkdir /usr/local/src/python
mkdir /usr/local/src/yum

下载python以及yum的rpm包

需要注意的是centos8已经停止维护了,所以要从centos8-stream找替代的安装包:https://pkgs.org/ 可以在此网站上搜索相关安装包

#python
cd /usr/local/src/python
wget http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/python3-asn1crypto-0.24.0-3.el8.noarch.rpm
wget http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/python3-dnf-4.7.0-4.el8.noarch.rpm
wget http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/python3-gpg-1.13.1-9.el8.x86_64.rpm
wget http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/python3-hawkey-0.63.0-3.el8.x86_64.rpm
wget http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/python3-libcomps-0.1.16-2.el8.x86_64.rpm
wget http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/python3-libdnf-0.63.0-3.el8.x86_64.rpm
wget http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/python3-libs-3.6.8-41.el8.x86_64.rpm
wget http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/python3-rpm-4.14.3-19.el8.x86_64.rpm
wget http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/platform-python-3.6.8-41.el8.x86_64.rpm
#yum
cd /usr/local/src/yum
wget http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/yum-4.7.0-4.el8.noarch.rpm
wget http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/yum-utils-4.0.21-3.el8.noarch.rpm

三、安装

安装python以及yum的rpm包

#安装Python
cd /usr/local/src/python
#Centos7
rpm -ivh python-*   rpm-python-* --nodeps --force
#Centos8
rpm -ivh python3-* platform-python-* --nodeps --force
#安装yum
cd /usr/local/src/yum
rpm -ivh yum-*

大功告成!

参考文档:

https://www.mxlong.com/14.html


#centos #linux #yum
目录
复制 复制成功