Linux误删python导致yum不可用,删除重装方法。

Linux 系统为 CentOS Linux release 7.4.1708

手贱、手贱、手贱 删了python 导致yum不可用。百度一大圈,重装yum和python后,老是报各种各样的错。历经磨难,终于自己总结了一套,亲测可用,分享一下。

转自:https://www.cnblogs.com/mashuqi/p/10955089.html


    1. 首先卸载现有python
      1.  
        rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps #卸载python
      2.  
        whereis python |xargs rm -frv ##删除所有残余文件
      3.  
        whereis python ##验证删除,返回无结果

       

    2.  删除现有的yum
      1.  
        rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps #删除yum
      2.  
        whereis yum |xargs rm -frv #删除残留文件
      3.  
        whereis yum #验证删除完成
    3. 找到下载文件源
      首先在这里找到服务器对应的版本,如 7.4.1708 进入这里目录 找到对应版本的rpm,替换下面的文件。

    4. 下载并安装,注意顺序,先安装python 然后 yum。不然安装后还会报错,重新来一遍。

      1.  
        # python安装
      2.  
        rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-2.7.5-58.el7.x86_64.rpm
      3.  
        rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-devel-2.7.5-58.el7.x86_64.rpm
      4.  
        rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
      5.  
        rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-libs-2.7.5-58.el7.x86_64.rpm
      6.  
        rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
      7.  
        rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
      8.  
        rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/rpm-python-4.11.3-25.el7.x86_64.rpm
      9.  
         
      10.  
        # yum安装
      11.  
        rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-3.4.3-154.el7.centos.noarch.rpm
      12.  
        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
      13.  
        rpm -ivh --nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
    5. 验证 

      1.  
        #验证python
      2.  
        python
      3.  
        #验证yum
      4.  
        yum
      5.  

posted @ 2023-04-18 14:25  principles  阅读(138)  评论(0编辑  收藏  举报