Centos 7删除python2.7后yum无法使用了

0. 曾经手贱了好几次, 也重装了好几次, 还是记下来吧...


1. 删除现有python

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

2. 删除现有yum

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

3. 重新下载rpm安装包, 注意版本号, 可能和下面的不一致.

https://mirrors.ustc.edu.cn/centos/7.9.2009/os/x86_64/Packages/

python-2.7.5-88.el7.x86_64.rpm
python-devel-2.7.5-88.el7.x86_64.rpm
python-libs-2.7.5-88.el7.x86_64.rpm
python-pycurl-7.19.0-19.el7.x86_64.rpm
python-setuptools-0.9.8-7.el7.noarch.rpm 
python-urlgrabber-3.10-10.el7.noarch.rpm  
python-iniparse-0.4-9.el7.noarch.rpm
rpm-python-4.11.3-43.el7.x86_64.rpm
yum-3.4.3-167.el7.centos.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm 
yum-utils-1.1.31-53.el7.noarch.rpm
yum-plugin-fastestmirror-1.1.31-53.el7.noarch.rpm
yum-plugin-protectbase-1.1.31-53.el7.noarch.rpm
yum-plugin-aliases-1.1.31-53.el7.noarch.rpm

4. 安装下载下来的rpm包

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

5. 验证yum是否可用!

Snipaste_2020-09-23_18-17-37.png
已经满血复活了!