1.卸载python
# 强制删除已安装程序及其关联
rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps
# 删除所有残余文件 #xargs,允许你对输出执行其他某些命令
whereis python|xargs rm -frv
2.卸载yum
rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
rm -rf /etc/yum.repos.d/*
whereis yum|xargs rm -frv
3.验证是否删除干净
# 验证删除,应该是没有结果返回
whereis python
whereis yum
4.安装python和yum
# 安装python2
rpm -ivh --nodeps http://vault.centos.org/7.3.1611/os/x86_64/Packages/python-2.7.5-48.el7.x86_64.rpm
rpm -ivh --nodeps http://vault.centos.org/7.3.1611/os/x86_64/Packages/python-devel-2.7.5-48.el7.x86_64.rpm
rpm -ivh --nodeps http://vault.centos.org/7.3.1611/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
rpm -ivh --nodeps http://vault.centos.org/7.3.1611/os/x86_64/Packages/python-libs-2.7.5-48.el7.x86_64.rpm
rpm -ivh --nodeps http://vault.centos.org/7.3.1611/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
rpm -ivh --nodeps http://vault.centos.org/7.3.1611/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
rpm -ivh --nodeps http://vault.centos.org/7.3.1611/os/x86_64/Packages/rpm-python-4.11.3-21.el7.x86_64.rpm
# 安装yum
rpm -ivh --nodeps http://vault.centos.org/7.3.1611/os/x86_64/Packages/yum-3.4.3-150.el7.centos.noarch.rpm
rpm -ivh --nodeps http://vault.centos.org/7.3.1611/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -ivh --nodeps http://vault.centos.org/7.3.1611/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm
参考链接
http://www.ay1.cc/article/1672650503533635676.htmlhttps://blog.csdn.net/qq_50843126/article/details/127694867
评论