rpm -qa|grep python|xargs rpm -e --allmatches --nodeps``whereis python|xargs rm -rf
[ root@centos6 ~]# rpm -qa|grep python|xargs rpm -e --allmatches --nodeps
warning: erase unlink of/usr/lib/python2.6/site-packages/pip/wheel.pyo failed: No such file or directory
warning: erase unlink of/usr/lib/python2.6/site-packages/pip/wheel.pyc failed: No such file or directory
warning: erase unlink of/usr/lib/python2.6/site-packages/pip/wheel.py failed: No such file or directory
warning: erase unlink of/usr/lib/python2.6/site-packages/pip/vcs/subversion.pyo failed: No such file or directory
warning: erase unlink of/usr/lib/python2.6/site-packages/pip/vcs/subversion.pyc failed: No such file or directory
[ root@centos6 ~]# whereis python
python:/usr/bin/python3.6/usr/lib/python2.6/usr/lib64/python2.6[root@centos6 ~]#
[ root@centos6 ~]# whereis python|xargs rm -fr
[ root@centos6 ~]#
[ root@centos6 ~]# whereis python
python:[root@centos6 ~]#
Check if you can still use python
[ root@centos6 ~]# python
- bash:/usr/bin/python: No such file or directory
[ root@centos6 ~]#
[ root@centos6 ~]# python3
- bash: python3: command not found
[ root@centos6 ~]#
[ root@centos6 ~]# python3.6-bash: python3.6: command not found
[ root@centos6 ~]#
[ root@centos6 ~]#
rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps``rm -rf /etc/yum.repos.d/*``whereis yum | xargs rm -rf
[ root@centos6 ~]# rpm -qa|grep yum
PackageKit-yum-plugin-0.5.8-26.el6.x86_64
yum-utils-1.1.30-41.el6.noarch
PackageKit-yum-0.5.8-26.el6.x86_64
yum-plugin-fastestmirror-1.1.30-41.el6.noarch
yum-metadata-parser-1.1.2-16.el6.x86_64
yum-3.2.29-81.el6.centos.noarch
yum-plugin-security-1.1.30-41.el6.noarch
[ root@centos6 ~]#
[ root@centos6 ~]# rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps
[ root@centos6 ~]# rm -rf /etc/yum.repos.d/*
[ root@centos6 ~]#
[ root@centos6 ~]# whereis yum
yum: /etc/yum
[ root@centos6 ~]#
[ root@centos6 ~]# whereis yum | xargs rm -rf
[ root@centos6 ~]#
[ root@centos6 ~]# whereis yum
yum:
[ root@centos6 ~]#
[ root@centos6 ~]# cat /etc/issue
CentOS release 6.10(Final)
Kernel \r on an \m
[ root@centos6 ~]#
Follow-up to find the mirror download according to the system version number.
First search Centos to find the mirror download, and then find the mirror library from the mirror download.
These are all mirror libraries, find the correct version of your system to download.
Set the path /centos/6.10/os/x86_64/Packages/
after the mirror url to find the address of the mirror library, as follows:
Create the python installation directory:
[ root@centos6 ~]# mkdir -p /usr/local/src/python
Download the installation file:
wget http://mirrors.163.com/centos/6.10/os/x86_64/Packages/python-2.6.6-66.el6_8.x86_64.rpm
wget http://mirrors.163.com/centos/6.10/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget http://mirrors.163.com/centos/6.10/os/x86_64/Packages/python-pycurl-7.19.0-9.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6.10/os/x86_64/Packages/python-devel-2.6.6-66.el6_8.x86_64.rpm
wget http://mirrors.163.com/centos/6.10/os/x86_64/Packages/python-libs-2.6.6-66.el6_8.x86_64.rpm
wget http://mirrors.163.com/centos/6.10/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
wget http://mirrors.163.com/centos/6.10/os/x86_64/Packages/rpm-python-4.8.0-59.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6.10/os/x86_64/Packages/python-setuptools-0.6.10-4.el6_9.noarch.rpm
The rpm file after downloading:
[ root@centos6 python]# ls
python-2.6.6-66.el6_8.x86_64.rpm python-iniparse-0.3.1-2.1.el6.noarch.rpm python-pycurl-7.19.0-9.el6.x86_64.rpm rpm-python-4.8.0-59.el6.x86_64.rpm
python-devel-2.6.6-66.el6_8.x86_64.rpm python-libs-2.6.6-66.el6_8.x86_64.rpm python-urlgrabber-3.9.1-11.el6.noarch.rpm
[ root@centos6 python]#
Perform the installation:
rpm -ivh python-* rpm-python-*
[ root@centos6 python]# rpm -ivh python-* rpm-python-*
Preparing... ########################################### [100%]package python-libs-2.6.6-66.el6_8.x86_64 is already installed
package python-2.6.6-66.el6_8.x86_64 is already installed
package python-pycurl-7.19.0-9.el6.x86_64 is already installed
package python-urlgrabber-3.9.1-11.el6.noarch is already installed
package python-devel-2.6.6-66.el6_8.x86_64 is already installed
package python-iniparse-0.3.1-2.1.el6.noarch is already installed
[ root@centos6 python]#
[ root@centos6 python]# python
Python 2.6.6(r266:84292, Aug 182016,15:13:37)[GCC 4.4.720120313(Red Hat 4.4.7-17)] on linux2
Type "help","copyright","credits" or "license"for more information.>>>exit()
Create yum installation directory:
mkdir -p /usr/local/src/yum
Find the path of the rpm package to be downloaded:
[ root@centos6 yum]# curl http://mirrors.163.com/centos/6.10/os/x86_64/Packages/>1.txt
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 859 k 0 859k 00 442k 0--:--:--0:00:01--:--:-- 451k
[ root@centos6 yum]# ls
1. txt
[ root@centos6 yum]# vim 1.txt
[ root@centos6 yum]#
[ root@centos6 yum]# cat 1.txt | grep yum | grep centos.noarch.rpm
< a href="kabi-yum-plugins-1.0-2.el6.centos.noarch.rpm">kabi-yum-plugins-1.0-2.el6.centos.noarch.rpm</a>07-Jul-201118:577724<a href="yum-3.2.29-81.el6.centos.noarch.rpm">yum-3.2.29-81.el6.centos.noarch.rpm</a>23-Mar-201723:04 1018K
< a href="yum-cron-3.2.29-81.el6.centos.noarch.rpm">yum-cron-3.2.29-81.el6.centos.noarch.rpm</a>23-Mar-201722:59 46K
[ root@centos6 yum]#
[ root@centos6 yum]# cat 1.txt | grep yum | grep yum-metadata-parser
< a href="yum-metadata-parser-1.1.2-16.el6.x86_64.rpm">yum-metadata-parser-1.1.2-16.el6.x86_64.rpm</a>26-Sep-201112:25 27K
[ root@centos6 yum]#
[ root@centos6 yum]# cat 1.txt | grep yum | grep yum-plugin-fastestmirror
< a href="yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm">yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm</a>20-Jun-201819:43 33K
[ root@centos6 yum]#
Download the installation file:
wget http://mirrors.163.com/centos/6.10/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6.10/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6.10/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
wget http://mirrors.163.com/centos/6.10/os/x86_64/Packages/yum-utils-1.1.30-41.el6.noarch.rpm
wget http://mirrors.163.com/centos/6.10/os/x86_64/Packages/yum-plugin-protectbase-1.1.30-41.el6.noarch.rpm
wget http://mirrors.163.com/centos/6.10/os/x86_64/Packages/yum-plugin-aliases-1.1.30-41.el6.noarch.rpm
Downloaded rpm package
[ root@centos6 yum]# ls
1. txt yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
yum-3.2.29-81.el6.centos.noarch.rpm yum-plugin-protectbase-1.1.30-41.el6.noarch.rpm
yum-metadata-parser-1.1.2-16.el6.x86_64.rpm yum-utils-1.1.30-41.el6.noarch.rpm
yum-plugin-aliases-1.1.30-41.el6.noarch.rpm
[ root@centos6 yum]#
Install the rpm package
[ root@centos6 yum]# rpm -ivh yum-*--force --nodeps
Preparing... ########################################### [100%]1:yum-metadata-parser ########################################### [17%]2:yum-plugin-fastestmirro########################################### [33%]3:yum ########################################### [50%]4:yum-utils ########################################### [67%]5:yum-plugin-aliases ########################################### [83%]6:yum-plugin-protectbase ########################################### [100%][root@centos6 yum]#
Execute yum
[ root@centos6 yum]# yum
Loaded plugins: aliases, fastestmirror, protectbase
You need to give some command
Usage: yum [options] COMMAND
List of Commands:
alias Adds or lists aliases
check Check for problems in the rpmdb
check-update Check for available package updates
clean Remove cached data
deplist List a package's dependencies
distribution-synchronization Synchronize installed packages to the latest available versions
downgrade downgrade a package[root@centos6 yum]# ls /etc/yum.repos.d/[root@centos6 yum]#
You can see that the yum source files of Centos6 have been deleted and need to be retrieved.
[ root@centos6 yum.repos.d]# cat CentOS-Base.repo
[ base]
name=CentOS-$releasever
enabled=1
failovermethod=priority
baseurl=http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.cloud.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-6
http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6[updates]
name=CentOS-$releasever
enabled=1
failovermethod=priority
baseurl=http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.cloud.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-6
http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6[extras]
name=CentOS-$releasever
enabled=1
failovermethod=priority
baseurl=http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.cloud.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-6
http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6[root@centos6 yum.repos.d]#
[ root@centos6 yum.repos.d]# cat epel.repo
[ epel]
name=Extra Packages for Enterprise Linux 6- $basearch
enabled=1
failovermethod=priority
baseurl=http://mirrors.cloud.aliyuncs.com/epel/6/$basearch
http://mirrors.aliyun.com/epel/6/$basearch
gpgcheck=0
gpgkey=http://mirrors.cloud.aliyuncs.com/epel/RPM-GPG-KEY-EPEL-6
http://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-6[root@centos6 yum.repos.d]#
[ root@centos6 yum.repos.d]# yum makecache
Loaded plugins: aliases, fastestmirror, protectbase
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base |3.7 kB 00:00
epel |4.7 kB 00:00
epel/filelists_db |7.9 MB 00:00
epel/updateinfo |817 kB 00:00
epel/prestodelta |1.3 kB 00:00
epel/other_db |3.0 MB 00:00
extras |3.4 kB 00:00
extras/prestodelta |2.2 kB 00:00
extras/other_db |14 kB 00:00
updates |3.4 kB 00:00
updates/filelists_db |3.0 MB 00:00
updates/prestodelta |153 kB 00:00
updates/other_db |213 kB 00:00
Metadata Cache Created
[ root@centos6 yum.repos.d]#
Test installation:
[ root@centos6 yum.repos.d]# yum install -y tree
Loaded plugins: aliases, fastestmirror, protectbase
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
0 packages excluded due to repository protections
Resolving Dependencies
- - > Running transaction check
- - - > Package tree.x86_64 0:1.5.3-3.el6 will be installed
- - > Finished Dependency Resolution
Okay, yum is installed here. If there are other files, you can refer to the following document, which is also very good.
Check whether the python pointed to by yum is 2.6.6
[ root@centos6 python]# head -1/usr/bin/yum
#! /usr/bin/python
[ root@centos6 python]#
[ root@centos6 python]# head -1/usr/bin/yum
#! /usr/bin/python
[ root@centos6 python]# /usr/bin/python --version
Python 2.6.6[root@centos6 python]#
Recommended Posts