阿里云centos7 重新安装python2.7及yum

完全重装python和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、从http://mirrors.ustc.edu.cn/centos/6.4/os/x86_64/Packages/下载相应的包
libxml2-2.9.1-6.el7_2.3.i686.rpm python-pycurl-7.19.0-19.el7.x86_64.rpm
libxml2-2.9.1-6.el7_2.3.x86_64.rpm python-setuptools-0.9.8-7.el7.noarch.rpm
libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm python-urlgrabber-3.10-8.el7.noarch.rpm
lvm2-python-libs-2.02.177-4.el7.x86_64.rpm rpm-4.11.3-32.el7.x86_64.rpm
python-2.7.5-68.el7.x86_64.rpm rpm-python-4.11.3-32.el7.x86_64.rpm
python-backports-1.0-8.el7.x86_64.rpm yum-3.4.3-158.el7.centos.noarch.rpm
python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
python-chardet-2.2.1-1.el7_1.noarch.rpm yum-plugin-aliases-1.1.31-45.el7.noarch.rpm
python-iniparse-0.4-9.el7.noarch.rpm yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
python-ipaddress-1.0.16-2.el7.noarch.rpm yum-plugin-protectbase-1.1.31-45.el7.noarch.rpm
python-kitchen-1.1.1-5.el7.noarch.rpm yum-utils-1.1.31-45.el7.noarch.rpm

由于源中版本会更新,具体请查看URL中的版本再下载下来!
4安装
[root@test ~]# rpm -Uvh –replacepkgs python*.rpm
[root@test ~]# rpm -Uvh –replacepkgs rpm-python*.rpm yum*.rpm
5安装过程中如遇到依赖报错
这里写图片描述
阿里云centos7 重新安装python2.7及yum_第1张图片
解决:1.下载wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-32.el7.x86_64.rpm
2.安装rpm -ivh libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm

5.完成测试
阿里云centos7 重新安装python2.7及yum_第2张图片
参照:
https://www.cnblogs.com/wangjunjiehome/p/9239005.html
https://blog.csdn.net/one312/article/details/81051023
http://blog.51cto.com/welcomeweb/2132654

你可能感兴趣的:(liunx,centos)