Linux deleted python by mistake, resulting in the unavailability of yum. Delete the reinstallation method.

Keywords: RPM Python yum CentOS

Linux system is CentOS Linux release 7.4.1708

Python is deleted by manual, manual, and manual, which makes yum unavailable. Baidu, after reinstalling yum and python, always reported all kinds of errors. After suffering, I finally summed up a set of personal tests, which can be used and shared.

  1. Uninstall existing python first
    rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps #Uninstall python
    whereis python |xargs rm -frv	 ##Delete all remaining files
    whereis python ##Verify delete, no result returned

     

  2. Delete existing yum
    rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps #Delete yum
    whereis yum |xargs rm -frv #Delete residual files
    whereis yum #Verify deletion complete
  3. Download source found
    First of all Here Find the corresponding version of the server, as shown in 7.4.1708 Here Directory to find the corresponding version of rpm, replace the following file.

  4. Download and install. Pay attention to the order. Install python first and then yum. Otherwise, an error will be reported after installation, and it will be repeated.

    # python installation
    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 installation
    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
  5. Verification

    #Verify python
    python
    #Verify yum
    yum


     

     

Posted by stereo on Wed, 20 Nov 2019 09:48:02 -0800