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!
++++++++++++++++++++++++++++++++++++++++++++
[ 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