Centos 重装Python2.7
一、删除现有的python
[root@test ~]# rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联 [root@test ~]# whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令 [root@test ~]# whereis python ##验证删除,返回无结果
二、删除现有的yum
[root@test ~]# rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps [root@test ~]# whereis yum |xargs rm -frv
三、从中科,163或者阿里云镜像下载相对应的包
下载地址:
中科: http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/
163 : http://mirrors.163.com/centos/7/os/x86_64/Packages/
阿里: https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
下载清单:根据最新版本酌情选择
python-libs-2.7.5-48.el7.x86_64.rpm,被python依赖
python-2.7.5-48.el7.x86_64.rpm
python-iniparse-0.4-9.el7.noarch.rpm, 被yum依赖
python-pycurl-7.19.0-19.el7.x86_64.rpm, 被python-urlgrabber依赖
python-urlgrabber-3.10-8.el7.noarch.rpm , 被yum依赖
rpm-python-4.11.3-21.el7.x86_64.rpm , 被yum依赖
下载后的安装方式
#rpm -ivh xxx.rpm
以下以163为参考
#wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-libs-2.7.5-89.el7.x86_64.rpm
#wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-2.7.5-89.el7.x86_64.rpm
#wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
#wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
#wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
#wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-python-4.11.3-45.el7.x86_64.rpm
#rpm -ivh python-libs-2.7.5-89.el7.x86_64.rpm
#rpm -ivh python-2.7.5-89.el7.x86_64.rpm
#rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
#rpm -ivh python-pycurl-7.19.0-19.el7.x86_64.rpm
#rpm -ivh python-urlgrabber-3.10-10.el7.noarch.rpm
#rpm -ivh rpm-python-4.11.3-45.el7.x86_64.rpm
四、下载yum安装包
下载清单:根据最新版本酌情选择
yum-3.4.3-150.el7.centos.noarch.rpm, 就是它依赖了上面的python库
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm
yum安装也按照顺序执行,在执行第一个rpm时, 结尾加上 --nodeps参数强制安装
#wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
#wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
#wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
#rpm -Uvh yum-3.4.3-168.el7.centos.noarch.rpm --nodeps
#yum -Uvh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm --nodeps
#yum -Uvh yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm --nodeps
如果接下来还是提示yum有问题,可以通过#rpm -ivh http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm --force解决
最后大功告成!!!
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm