Centos7 python2.7和yum完全卸载及重装
1、删除现有Python
[root@test ~]# rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联
[root@test ~]# whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
[root@test ~]# whereis python ##验证删除,返回无结果
2、删除现有的yum
[root@test ~]# rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
[root@test ~]# whereis yum |xargs rm -frv
3、下载rpm安装包
先查看自己linux系统版本:
[root@master yum2]# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
发现版本号是7.8.2003,所以去找该版本号的包下载。
下载地址:
http://mirrors.163.com/centos/7.8.2003/os/x86_64/Packages/
创建目录python和yum用以存放rpm包
mkdir /usr/local/src/python
mkdir /usr/local/src/yum
使用wget分别下载python以及yum的rpm包
1)下载python包,进入python 目录
#cd /usr/local/src/python
wget http://mirrors.163.com/centos/7.8.2003/os/x86_64/Packages/python-2.7.5-88.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7.8.2003/os/x86_64/Packages/python-devel-2.7.5-88.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7.8.2003/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.8.2003/os/x86_64/Packages/python-libs-2.7.5-88.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7.8.2003/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7.8.2003/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
2)下载yum包,进入yum目录
#cd /usr/local/src/yum
wget http://mirrors.163.com/centos/7.8.2003/os/x86_64/Packages/yum-3.4.3-167.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7.8.2003/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7.8.2003/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-53.el7.noarch.rpm
4、安装python以及yum的rpm包
(1)安装python:
#rpm -ivh python-* rpm-python-* --nodeps --force
--nodeps --force为不考虑依赖包,强制安装。
安装完后即可运行python:
(2)安装yum:
#cd /usr/local/src/yum
#rpm -ivh yum-*
网友评论