此文參照https://www.cnblogs.com/wangjunjiehome/p/9239005.html,特別感謝捻悯。
1福青、刪除現(xiàn)有Python
[root@test~]# rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##強(qiáng)制刪除已安裝程序及其關(guān)聯(lián)
[root@test~]# whereis python |xargs rm -frv ##刪除所有殘余文件 ##xargs旦签,允許你對(duì)輸出執(zhí)行其他某些命令
[root@test~]# whereis python ##驗(yàn)證刪除拾稳,返回?zé)o結(jié)果
2、刪除現(xiàn)有的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/ 或者?https://mirrors.aliyun.com/centos下載相應(yīng)的包醉锄,這個(gè)時(shí)候要查看自己系統(tǒng)的版本乏悄,很重要cat /etc/redhat-release? ?--? ?CentOS Linux release 7.7.1908 (Core)?
4.創(chuàng)建目錄python和和yum用以存放rpm包
#mkdir /usr/local/src/python
#mkdir /usr/local/src/yum
#cd /usr/local/src/python 進(jìn)入目錄
wget ftp://mirrors.ustc.edu.cn/centos/7.7.1908/os/x86_64/Packages/python-2.7.5-86.el7.x86_64.rpm
wget ftp://mirrors.ustc.edu.cn/centos/7.7.1908/os/x86_64/Packages/python-2.7.5-86.el7.x86_64.rpm
wget ftp://mirrors.ustc.edu.cn/centos/7.7.1908/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget ftp://mirrors.ustc.edu.cn/centos/7.7.1908/os/x86_64/Packages/python-devel-2.7.5-86.el7.x86_64.rpm
wget ftp://mirrors.ustc.edu.cn/centos/7.7.1908/os/x86_64/Packages/python-libs-2.7.5-86.el7.x86_64.rpm
wget ftp://mirrors.ustc.edu.cn/centos/7.7.1908/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
wget ftp://mirrors.ustc.edu.cn/centos/7.7.1908/os/x86_64/Packages/rpm-python-4.11.3-40.el7.x86_64.rpm
切換到y(tǒng)um目錄:cd /usr/local/src/yum
wget ftp://mirrors.ustc.edu.cn/centos/7.7.1908/os/x86_64/Packages/yum-3.4.3-163.el7.centos.noarch.rpm
wget ftp://mirrors.ustc.edu.cn/centos/7.7.1908/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget ftp://mirrors.ustc.edu.cn/centos/7.7.1908/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
執(zhí)行安裝?:
rpm -ivh python-* rpm-python-* --nodeps --force
rpm -ivh yum-*