卸载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
rpm开头的那几个大多数的文章老是没有提到,python的包也不够全!node
https://www.cnblogs.com/wangjunjiehome/p/9239005.htmlpython
- libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm
- python-2.7.5-68.el7.x86_64.rpm
- python-backports-1.0-8.el7.x86_64.rpm
- python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
- python-chardet-2.2.1-1.el7_1.noarch.rpm
- python-devel-2.7.5-68.el7.x86_64.rpm
- python-iniparse-0.4-9.el7.noarch.rpm
- python-ipaddress-1.0.16-2.el7.noarch.rpm
- python-kitchen-1.1.1-5.el7.noarch.rpm
- python-libs-2.7.5-68.el7.x86_64.rpm
- python-pycurl-7.19.0-19.el7.x86_64.rpm
- python-setuptools-0.9.8-7.el7.noarch.rpm
- python-urlgrabber-3.10-8.el7.noarch.rpm
- python-virtualenv-15.1.0-2.el7.noarch.rpm
- rpm-4.11.3-32.el7.x86_64.rpm
- rpm-build-4.11.3-32.el7.x86_64.rpm
- rpm-build-libs-4.11.3-32.el7.x86_64.rpm
- rpm-libs-4.11.3-32.el7.x86_64.rpm
- rpm-python-4.11.3-32.el7.x86_64.rpm
- rpm-sign-4.11.3-32.el7.x86_64.rpm
- yum-3.4.3-158.el7.centos.noarch.rpm
- yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
- yum-plugin-aliases-1.1.31-45.el7.noarch.rpm
- yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
- yum-plugin-protectbase-1.1.31-45.el7.noarch.rpm
- 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.curlIt'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)]ideIf 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
结束。