centos7.6删除重新安装python和yum
最近在开发一个项目时出现了错误,需要重新安装python和yum,怎么安装呢?随ytkah一起来看看吧。ytkah用的linux分支的centos7.6,各位朋友在下载源的时候要注意版本的区分。现在开始:
1.1删除现有python
1 2 3 | rpm -qa| grep python| xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联 whereis python | xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令 whereis python ##验证删除,返回无结果 |
1.2删除现有yum
1 2 | rpm -qa| grep yum| xargs rpm -ev --allmatches --nodeps whereis yum | xargs rm -frv |
2.1然后到http://mirrors.ustc.edu.cn/centos/找到对应的centos版本下载相应的包,我的是centos7.6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/python-2 .7.5-76.el7.x86_64.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/python-devel-2 .7.5-76.el7.x86_64.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/python-iniparse-0 .4-9.el7.noarch.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/python-libs-2 .7.5-76.el7.x86_64.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/python-pycurl-7 .19.0-19.el7.x86_64.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/python-setuptools-0 .9.8-7.el7.noarch.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/python-urlgrabber-3 .10-9.el7.noarch.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/python-backports-ssl_match_hostname-3 .5.0.1-1.el7.noarch.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/python-backports-1 .0-8.el7.x86_64.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/python-ipaddress-1 .0.16-2.el7.noarch.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/libxml2-python-2 .9.1-6.el7_2.3.x86_64.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/python-kitchen-1 .1.1-5.el7.noarch.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/python-chardet-2 .2.1-1.el7_1.noarch.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/rpm-python-4 .11.3-35.el7.x86_64.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/yum-3 .4.3-161.el7.centos.noarch.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/yum-metadata-parser-1 .1.4-10.el7.x86_64.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/yum-utils-1 .1.31-50.el7.noarch.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/yum-plugin-fastestmirror-1 .1.31-50.el7.noarch.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/yum-plugin-protectbase-1 .1.31-50.el7.noarch.rpm wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/yum-plugin-aliases-1 .1.31-50.el7.noarch.rpm |
2.2然后分别安装python和yum
1 2 | rpm -Uvh --replacepkgs python*.rpm rpm -Uvh --replacepkgs rpm-python*.rpm yum*.rpm |
如果提示libxml2-python is needed by yum-utils-1.1.31-50.el7.noarch那么要先安装libxml2-python
1 | wget http: //mirrors .ustc.edu.cn /centos/7 .6.1810 /os/x86_64/Packages/libxml2-python-2 .9.1-6.el7_2.3.x86_64.rpm |
然后执行
1 | rpm -Uvh --replacepkgs libxml2-python*.rpm |
3运行python进行测试,直接输入python
1 | python<br>yum update |

加微信交流
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
2017-01-05 微信小程序与传统APP十大优劣对比