Linux误删python导致yum不可用,删除重装方法。
Linux 系统为 CentOS Linux release 7.4.1708
手贱、手贱、手贱 删了python 导致yum不可用。百度一大圈,重装yum和python后,老是报各种各样的错。历经磨难,终于自己总结了一套,亲测可用,分享一下。
转自:https://www.cnblogs.com/mashuqi/p/10955089.html
- 首先卸载现有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 #删除残留文件
-
whereis yum #验证删除完成
-
-
找到下载文件源
首先在这里找到服务器对应的版本,如 7.4.1708 进入这里目录 找到对应版本的rpm,替换下面的文件。 -
下载并安装,注意顺序,先安装python 然后 yum。不然安装后还会报错,重新来一遍。
-
# python安装
-
rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-2.7.5-58.el7.x86_64.rpm
-
rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-devel-2.7.5-58.el7.x86_64.rpm
-
rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
-
rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-libs-2.7.5-58.el7.x86_64.rpm
-
rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
-
rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
-
rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/rpm-python-4.11.3-25.el7.x86_64.rpm
-
-
# yum安装
-
rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-3.4.3-154.el7.centos.noarch.rpm
-
rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-
rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
-
-
验证
-
#验证python
-
python
-
#验证yum
-
yum
-
-