CentOS7.2的yum、python卸载和从新安装【亲测有效!20190626】

第一步 

卸载python、yum(yum依赖于python)html

一、删除现有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

 

第二步 

大多数的文章基本流程都没问题,重要的是导入包的数量不够(必须是26个!!!)

rpm开头的那几个大多数的文章老是没有提到,python的包也不够全!node

https://www.cnblogs.com/wangjunjiehome/p/9239005.htmlpython

  1. libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm
  2. python-2.7.5-68.el7.x86_64.rpm
  3. python-backports-1.0-8.el7.x86_64.rpm
  4. python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
  5. python-chardet-2.2.1-1.el7_1.noarch.rpm
  6. python-devel-2.7.5-68.el7.x86_64.rpm
  7. python-iniparse-0.4-9.el7.noarch.rpm
  8. python-ipaddress-1.0.16-2.el7.noarch.rpm
  9. python-kitchen-1.1.1-5.el7.noarch.rpm
  10. python-libs-2.7.5-68.el7.x86_64.rpm
  11. python-pycurl-7.19.0-19.el7.x86_64.rpm
  12. python-setuptools-0.9.8-7.el7.noarch.rpm
  13. python-urlgrabber-3.10-8.el7.noarch.rpm
  14. python-virtualenv-15.1.0-2.el7.noarch.rpm
  15. rpm-4.11.3-32.el7.x86_64.rpm
  16. rpm-build-4.11.3-32.el7.x86_64.rpm
  17. rpm-build-libs-4.11.3-32.el7.x86_64.rpm
  18. rpm-libs-4.11.3-32.el7.x86_64.rpm
  19. rpm-python-4.11.3-32.el7.x86_64.rpm
  20. rpm-sign-4.11.3-32.el7.x86_64.rpm
  21. yum-3.4.3-158.el7.centos.noarch.rpm
  22. yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
  23. yum-plugin-aliases-1.1.31-45.el7.noarch.rpm
  24. yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
  25. yum-plugin-protectbase-1.1.31-45.el7.noarch.rpm
  26. yum-utils-1.1.31-45.el7.noarch.rpm
     

 

若是,缺乏包就出现以下报错(差点绝望):linux

There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:centos

   /usr/lib64/python2.7/site-packages/rpm/_rpm.so: undefined symbol: rpmpkgVerifySipython2.7

Please install a package which provides this module, or
verify that the module is installed correctly.curl

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.5 (default, Apr 11 2018, 07:36:10)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]ide

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://yum.baseurl.org/wiki/Faqui

多谢这篇文章:https://blog.csdn.net/qq_36731677/article/details/83552436this


第三步 

官方下载地址:http://mirror.centos.org/centos/7/os/x86_64/Packages/

我当时找起来至关费劲,因此分享到百度云直接下载,不用找了,可是版本得匹配(CentOS Linux 7.2.1511)

百度云分享:https://pan.baidu.com/s/1w6J-tnGNuArjt1J3xVv7sA      提取码: kgwd 

CentOS6.8的就只能本身去下载了http://mirror.centos.org/centos/6/os/x86_64/Packages/


第四步 

安装python以及yum的rpm包

在 linux上新建两个文件夹python和yum,分别放这两个库

(python目录下)安装python指令

#rpm -ivh python-*   rpm-python-* --nodeps --force

--nodeps --force为不考虑依赖包,强制安装。

安装完后便可运行python, 退出python命令行的方法 快捷键 Ctrl+D

(yum目录下)安装yum:

#rpm -ivh yum-* --nodeps --force

 

再运行yum命令就好 , 重点就是导包要全!!!

结束。