CentOS7.3.1611卸载并重新安装python2.7及yum

安装python2.7需要与centos内核版本保持一致,否则会出现冲突

1、查看centos内核版本

[root@067mqtt2]# cat /etc/redhat-release cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

2、卸载

卸载python:

#rpm -qa|grep python|xargs rpm -e --allmatches --nodeps

#whereis python|xargs rm -fr

卸载yum:

#rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps

#rm -rf /etc/yum.repos.d/*

#whereis yum|xargs rm -fr

3.创建目录python和yum用以存放rpm包:

#mkdir /usr/local/src/python

#mkdir /usr/local/src/yum

4.使用wget分别下载python以及yum的rpm包(注意:一定要和系统的版本号对应)

(1)下载python的rpm包:

#cd /usr/local/src/python        进入目录

#wget http://vault.centos.org/7.3.1611/os/x86_64/Packages/python-2.7.5-48.el7.x86_64.rpm
#wget http://vault.centos.org/7.3.1611/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
#wget http://vault.centos.org/7.3.1611/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
#wget http://vault.centos.org/7.3.1611/os/x86_64/Packages/python-devel-2.7.5-48.el7.x86_64.rpm
#wget http://vault.centos.org/7.3.1611/os/x86_64/Packages/python-libs-2.7.5-48.el7.x86_64.rpm
#wget http://vault.centos.org/7.3.1611/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
#wget http://vault.centos.org/7.3.1611/os/x86_64/Packages/rpm-python-4.11.3-21.el7.x86_64.rpm

(2)下载yum的rpm包:

#cd /usr/local/src/yum        

#wget http://vault.centos.org/7.3.1611/os/x86_64/Packages/yum-3.4.3-150.el7.centos.noarch.rpm
#wget http://vault.centos.org/7.3.1611/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
#wget http://vault.centos.org/7.3.1611/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm

5.安装python以及yum的rpm包

(1)安装python:

#cd /usr/local/src/python 

#rpm -ivh python-*   rpm-python-* 

       出现安装包的依赖问题,此时如下解决即可:

rpm -ivh python-* rpm-python-* –nodeps –force

        --nodeps --force为不考虑依赖包,强制安装。

        安装完后即可运行python:


(2)安装yum:

#cd /usr/local/src/yum 

#rpm -ivh yum-* 

    至此yum重新安装成功!

你可能感兴趣的:(Linux)