Abstract:
From the title, you can see that I’m paranoid, but a brief description of how I hurt myself.
① Because you need to deploy the crawler first, then install Python3.
②Python3 and Python2 are not backward compatible, so I uninstalled the native version of Python2.7 and cleaned it up.
③ Then I downloaded the Python3.8 package.
④ I started using yum to install Python3.8 dependencies.
⑤ Yum is not available
See the problem hint just know is oneself dug a pit for oneself, the mood once gloomy arrive even dinner all don’t want to eat, finally? I finally went to dinner, hahaha.
One. Facing problems
Not only was YUM unavailable due to Python2.7 being uninstalled, but the machine in my Ambari cluster crashed and the Web interface went red as I tried to pass the command
rm -rf /*
Copy the code
The impulse to delete the machine. Simply put, the problem is to return to the original state.
The idea is that without Python2.7, I need to reinstall the Python2.7 package that the Linux server relies on and see if there are any other problems. If there are no problems, I’m fine. If there are problems, I’ll read the prompts and get to work.
This process also applies to the problem where the Python version of YUM is unavailable. For different versions of the machine, remember to replace the machine version number.
Check whether the deletion is complete
2.1. Check that Python2.7 is uninstalled clean
#Uninstall python
rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps
#Delete all remaining files
whereis python |xargs rm -frv
#No result is returned
whereis python
Copy the code
2.2. Delete existing yum
Unusable delete first, in case dependency error
#Delete the yum!
rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
#Deleting Residual Files
whereis yum |xargs rm -frv
#No result is displayed
whereis yum
Copy the code
Download, install and restore
3.1. View the Linux Version
If you want to install Python2.7, you need to find the Linux version number. If you want to install Python2.7, you need to find the Linux version number.
#The command
cat /etc/redhat-release
#The version number
CentOS Linux release 7.4.1708
Copy the code
3.2. Find the corresponding package on the official website
After checking the version number, I need to look up the specific packages I rely on from the official website (red Hat, pay attention to which manufacturer your CentOS comes from).
#The official website
http://vault.centos.org
#My version of the official website http://vault.centos.org/7.4.1708/os/x86_64/Packages/
#The following 7 packagesPython - 2.7.5-58. El7. X86_64. RPM python - devel - 2.7.5-58. El7. X86_64. RPM python - iniparse - 0.4-9. El7. Noarch. RPM Python - pycurl - 7.19.0-19. El7. X86_64. RPM RPM - python - 4.11.3-25. El7. X86_64. Rpmpython - devel - 2.7.5-58. El7. X86_64. RPM Python - libs - 2.7.5-58. El7. X86_64. RPM python - urlgrabber - 3.10-8 el7. Noarch. RPMCopy the code
3.3. Download and install Python packages
#Python installationRPM - the ivh -- nodeps RPM - the ivh -- nodeps at http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-2.7.5-58.el7.x86_64.rpm http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-devel-2.7.5-58.el7.x86_64.rpm RPM - the ivh -- nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm RPM - the ivh -- nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-libs-2.7.5-58.el7.x86_64.rpm RPM - the ivh -- nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm RPM - the ivh -- nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm RPM - the ivh -- nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/rpm-python-4.11.3-25.el7.x86_64.rpmCopy the code
3.4. Install the specified yum package
#Yum installThe RPM - the ivh -- nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-3.4.3-154.el7.centos.noarch.rpm RPM - the ivh http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm -- nodeps RPM - the ivh -- nodeps http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpmCopy the code
Four. Finishing up
4.1. Whether the test is successful
#Verify the python
python
#Verify the yum!
yum
Copy the code
4.2. Summarize
The moral of the story:
① Read more relevant materials in areas you don’t understand, not directly at the beginning.
② Clear thinking to solve problems.
Python3 must be installed
Use Python3.* without uninstalling the Python2 version
Environment: centos7.4
Version: python3.8
5.1. Dependency package Installation
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
Copy the code
5.2. Download Package:
#Download path (there are different versions) https://www.python.org/ftp/python/3.8.0/
#Download the commandWget HTTP: / / https://www.python.org/ftp/python/3.8.0/Python-3.8.tgzCopy the code
5.3 unzip:
The tar ZXVF Python - 3.8.0. TGZCopy the code
5.4. Installation:
CD Python - 3.8.0#Specify the compile directory
./configure --prefix=/usr/local/python3
#Compile the installation
make && make install
Copy the code
5.5. Establish a soft connection
Ln -s/usr/local/python3 / bin/python3.8 / usr/bin/python3 ln -s/usr/local/python3 / bin/pip3.8 / usr/bin/pip3Copy the code
5.6. Test if python3 works
python3
pip3
Copy the code
Daily nonsense
Today facing this problem is similar to a novice problem, but in many cases, they do not understand the situation is easy to produce this problem.
So let’s briefly talk about a solution to the problem we encountered.
① What problems encountered, first locate the problem is what.
② What operation did we do before this problem caused the related problem, because what caused this problem.
③ What is the error message for this problem?
④ Combining ② and ③ to find targeted solutions is often a step by step process of trial and error.
⑤ According to the solution to solve the problem.
It’s kind of like why, how, and what happens. Throwing it out in a panic or headless manner is the slowest way to solve a problem.
The formation of the above thinking can better help themselves to deal with problems in the actual work.
I’m Lubian,2020 Peace and Love.
As usual, my personal public account: Lubian She, welcome to pay attention to (background reply [machine learning], get relevant study notes)