首先卸载原来的yum

查看yum安装包

[root@yy48 ~]# rpm -qa|grep yum

yum-3.4.3-167.el7.noarch

yum-langpacks-0.4.2-7.el7.noarch

yum-rhn-plugin-2.0.1-10.el7.noarch

yum-utils-1.1.31-53.el7.noarch

yum-metadata-parser-1.1.4-10.el7.x86_64

2、将其全部卸载

#rpm -e xxxxxxxxxxxxxxxx

total 9124

-rw-r–r–. 1 root root 20192 Jul 3 2014 dbus-python-devel-1.1.1-9.el7.x86_64.rpm

-rw-r–r–. 1 root root 252824 Apr 3 17:01 libxml2-python-2.9.1-6.el7.4.x86_64.rpm

-rw-r–r–. 1 root root 192364 Apr 3 17:01 lvm2-python-libs-2.02.186-7.el7.x86_64.rpm

-rw-r–r–. 1 root root 97976 Apr 3 17:06 python-2.7.5-88.el7.x86_64.rpm

-rw-r–r–. 1 root root 12896 Apr 25 2018 python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm

-rw-r–r–. 1 root root 232448 Aug 22 2019 python-chardet-2.2.1-3.el7.noarch.rpm

-rw-r–r–. 1 root root 39800 Jul 4 2014 python-iniparse-0.4-9.el7.noarch.rpm

-rw-r–r–. 1 root root 35176 Nov 20 2016 python-ipaddress-1.0.16-2.el7.noarch.rpm

-rw-r–r–. 1 root root 273012 Jul 4 2014 python-kitchen-1.1.1-5.el7.noarch.rpm

-rw-r–r–. 1 root root 5918924 Apr 3 17:06 python-libs-2.7.5-88.el7.x86_64.rpm

-rw-r–r–. 1 root root 82396 Nov 20 2016 python-pycurl-7.19.0-19.el7.x86_64.rpm

-rw-r–r–. 1 root root 406404 Aug 10 2017 python-setuptools-0.9.8-7.el7.noarch.rpm

-rw-r–r–. 1 root root 111048 Apr 3 17:21 python-urlgrabber-3.10-10.el7.noarch.rpm

-rw-r–r–. 1 root root 85760 Apr 3 17:07 rpm-python-4.11.3-43.el7.x86_64.rpm

-rw-r–r–. 1 root root 1298672 Apr 3 17:30 yum-3.4.3-167.el7.centos.noarch.rpm

-rw-r–r–. 1 root root 28348 Jul 4 2014 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

-rw-r–r–. 1 root root 32016 Apr 3 17:30 yum-plugin-aliases-1.1.31-53.el7.noarch.rpm

-rw-r–r–. 1 root root 35004 Apr 3 17:30 yum-plugin-fastestmirror-1.1.31-53.el7.noarch.rpm

-rw-r–r–. 1 root root 27824 Apr 3 17:30 yum-plugin-protectbase-1.1.31-53.el7.noarch.rpm

-rw-r–r–. 1 root root 124628 Apr 3 17:30 yum-utils-1.1.31-53.el7.noarch.rpm

执行安装命令

#rpm -Uvh –replacepkgs lvm2-python-libs*.rpm –nodeps –force

#rpm -Uvh –replacepkgs libxml2-python*.rpm –nodeps –force

#rpm -Uvh –replacepkgs python*.rpm –nodeps –force

#rpm -Uvh –replacepkgs rpm-python*.rpm yum*.rpm –nodeps –force

如果将python换成python3的话,运行yum会报错

[root@iz2ze3ogy01eqvjs99e8nez python]# yum

File “/usr/bin/yum”, line 30

except KeyboardInterrupt, e:

^

SyntaxError: invalid syntax

修改 vi /etc/usr/yum 第一行为

#!/usr/bin/python2

14124e5d979c5bf34c4a04994eb9408b.png

80acc1ac2cff6ac0c3857c98e656cdc2.png

标签:rw,python,rpm,CentOS7,yum,root,安装,el7

来源: https://www.cnblogs.com/l7planet/p/12938105.html