CentOS7 repairs python to save yum

I was blowing on the air conditioner and drinking tea. Then my QQ portrait shook twice. The business development classmate greeted me, "Are you busy? Can I help you?" This is obvious, I'm busy! Come to live. Reply "you said" in the spirit of love and dedication. Then told me implicitly that yum is not easy to use. Come on, this job may be very simple, just compile a higher version by yourself to replace the system python, and then yum uses python. Due to the high version and lack of libraries, it cannot be used. Or it is particularly troublesome, just unload the python of the system! ! ! ! ! ! This may not be saved, it depends on whether the business classmates are merciful. That's the gossip!

++++++++++++++++++++++++++++++++++++++++++++

  1. To save yum, simply install a higher version of python, and then change the environment variables or soft link
[ root@test ~]# vim $(which yum)
#! /usr/bin/Change python to the python path of the system. For example:#!/usr/bin/python2.7import sys
try:import yum
except ImportError:
 print >> sys.stderr,"""\

And this place

[ root@test ~]# vi /usr/libexec/urlgrabber-ext-down 
#! /usr/bin/Change python to the python path of the system. For example:#!/usr/bin/python2.7  
# A very simple external downloader
# Copyright 2011-2012 Zdenek Pavlas

Then try it normally

Two hand shaking delete python or delete yum

the difference:

This is no python

[ root@test ~]# yum
- bash:/usr/bin/yum:/usr/bin/python: bad interpreter: No such file or directory
[ root@test ~]# python -V
- bash:/usr/bin/python: No such file or directory

This is no more yum

[ root@test ~]# yum
- bash:/usr/bin/yum: No such file or directory

If the identification is that both are gone, congratulations you are really a fucking talent. But fortunately, you read this article, so let's continue reading!

In fact, I have repaired the generation environment. For demonstration purposes, I used a virtual machine to do it here. Curious friends don't try it in the generation environment (it is best to be accompanied by an adult, and the consequences have nothing to do with me under the exemption)! ! !

The specific process is as follows:

Briefly:

a Find the rpm package of python and yum:

Use the yumdownloader command on the server of the same system to download the rpm package to another server, and then get it on this server:

 yumdownloader  python python-libs python-devel python-devel python-pycurl python-urlgrabber python-setuptools rpm-python yum-utils yum yum-metadata-parser yum-plugin-aliases yum-plugin-protectbase yum-plugin-fastestmirror python-kitchen python-chardet

or

Pay attention to find the following rpm package under the source consistent with your system version:

For example: centos7.2.151 The source address is: http://vault.centos.org/7.2.1511/os/x86_64/Packages/ Pay attention to the replacement version Official source

Wget the above source to the local

b Install the downloaded rpm package:

[ root@test ~]# rpm -Uvh --replacepkgs python*.rpm
[ root@test ~]#  rpm -Uvh --replacepkgs rpm-python*.rpm yum*.rpm

If there are dependencies in this process that need to install other rpm packages, you can find the installation prompt to find and install, do not skip!

c Installation is complete, test use

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Detailed process

1 Delete system python and yum (for demonstration, self-harm)

System environment and number of installation packages

Try to delete the system python, rpm direct -e deletion will see many dependencies, but the deletion is not successful

I deleted it with yum, but it didn't work this time. It shows that python is protected by the system. This is necessary python is very important to the system. This also shows that normal hand shaking can not delete centos7 python

Add some parameters and finally get it:

rpm -qa |grep python|xargs rpm -ev --allmatches --nodeps
rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
whereis python |xargs rm -fr
whereis yum |xargs rm -fr

Refer to Figure 1 to delete 77 rpm packages. . yum has been reimbursed, python is gone

This is to delete yum, and a few packages are missing. . .

Start to repair, but fortunately wget can be used, if not, then try rsync nc and so on to transfer rpm package,

The following figure shows that some rpm packages have been downloaded, and the dependencies will be reported during installation. Don't panic, go and download them, and then install them. If you are reporting dependencies, continue to find them and install them. . .

I can take a sigh of relief when I see this, this is a successful python repair

Then go to repair yum. This is when I encountered a dependency problem, and I have put all these packages in a simple step.

Successfully crossed the robbery, boy, python and yum are already available

Another way to download the rpm package is faster, but requires a server in the same environment:

There is a package here, there is no command

Here is the batch packing:

In addition, wrong posture demonstration: the package can not be installed, this is improper handling of dependencies

The story ends here.

++++++++++++++++++++++++++++++++++++++++++

How to put it, this story tells us: ① Pre-job training for new students is very important (this is done by an intern), hello, or him. You save trouble, he saves worry and frustration, career frustration.

② If the operation and maintenance classmates do not take action, they must solve the problem. In fact, after looking at the environment, I asked if I could reinstall it and pave the way first, which is also the time to reflect our professional skills.

Finally, a bowl of chicken soup, take a break early, or else your eyes will be dark, your hands will tremble, and you may not know what order you have ordered. Get more rest to defend your hairline! md can't make it through, hairline~<~

Recommended Posts

CentOS7 repairs python to save yum
Centos 6.4 python 2.6 upgrade to 2.7
CentOS 5 to CentOS 5.8 YUM source
Centos default python2.6 upgrade to
CentOS upgrade python2 to pyth
Centos 6.10 reinstall python and yum
How to save the python program
CentOS + Python3.6+
How to install Python 3.8 on CentOS 8
How to install Python on CentOS 8
Centos 7.5 python3.6
CentOS 6 add common yum source to transfer
R&amp;D: How To Install Python 3 on CentOS 7
Centos8 uses yum to install mongodb 4.2 method
Centos7 uses yum to install pip, ipython
Centos8 use yum to install rabbitmq tutorial
CentOS7 system yum way to install MySQL5.7
Centos6 install Python2.7.13
Centos7 install Python 3.6.
CentOS7 upgrade python3
CentOS install Python 3.6
Python - centos6 installation
Centos7 install Python2.7
Centos install Python3
CentOS6.8 install python2.7
Introduction to Python
Centos7 uses yum to install Apache, mariadb, PHP
Centos7 YUM install MariaDB 10.0
Centos source installation Python3
CentOS 7.2 Yum install MySQL 5.6
CentOS6.5 upgrade kernel to 3.10.28
CentOS comes with Python deleted &amp;&amp; YUM error repair
Centos7 YUM install MariaDB 10.0
How to save IE as an attachment in python
CentOS Python Java installations
Solution to python alignment error
Python code to find bugs (2)
Python code to find bugs(7)
How to comment python code
centos7 install python3 and ipython
centos install mysql through yum
Python code to find bugs (3)
Python code to find bugs(9)
Centos7.6 method to install Tomcat-8.5.39
How to learn python quickly
How to uninstall python plugin
Introduction to Python related modules
Python code to find bugs(6)
CentOS 6.9 compile and install python
Python code to find bugs (1)
Python code to find bugs(8)
3 ways to encrypt Python files
Centos6 install python3 pip3 ipython3
How to understand python objects
Python code to find bugs(5)
How to use python tuples
CentOS 6 compile and install python 3
Centos7 deploys python3 virtual environment
CentOS 7 yum install PHP7.3 tutorial
Update gcc to 6.4.0 in centos