no module named yum有效解决办法
1、事件描述
因误删系统python环境,导致yum不能使用,报错如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | There was a problem importing one of the Python modules required to run yum. The error leading to this problem was: No module named yum Please install a package which provides this module, or verify that the module is installed correctly. It's possible that the above module doesn't match the current version of Python, which is: 2.7.5 (default, Apr 2 2020, 13:16:51) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq |
2、解决办法
2.1卸载系统原有的yum安装包
1 2 3 4 5 6 | #强制删除系统安装程序yum包及其相关 rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps #删除所有残余文件 whereis yum |xargs rm -frv ##xargs,允许你对输出执行其他某些命令 #验证删除 whereis yum ##验证删除,返回无结果 |
2.2下载python需要的rpm包(存在包更新的情况,我这个帖子不会实时更新,如有过期,亲自己去搜索对于的名字,需要我的帮助,可以进行赞助,然后联系我)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-chardet-2.2.1-1.el6.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-libs-2.7.5-88.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/libxml2-python-2.9.1-6.el7.4.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/libsemanage-python-2.5-14.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/policycoreutils-python-2.5-34.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/libselinux-python-2.5-15.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-schedutils-0.4-6.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-linux-procfs-0.4.11-4.el7.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/dbus-python-1.1.1-9.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-firewall-0.6.3-8.el7.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-perf-3.10.0-1127.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-2.7.5-88.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-decorator-3.4.0-3.el7.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/audit-libs-python-2.8.5-4.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-IPy-0.75-6.el7.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-gobject-base-3.22.0-1.el7_4.1.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-slip-0.4.0-4.el7.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/newt-python-0.52.15-4.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-configobj-4.7.2-7.el7.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-python-4.11.3-43.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-slip-dbus-0.4.0-4.el7.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-pyudev-0.15-9.el7.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-libs-2.7.5-89.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/libxml2-python-2.9.1-6.el7.5.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-firewall-0.6.3-11.el7.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-perf-3.10.0-1160.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-2.7.5-89.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-python-4.11.3-45.el7.x86_64.rpm |
2.3下载yum所需的rpm包
1 2 3 4 5 6 | wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-aliases-1.1.31-54.el7_8.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-protectbase-1.1.31-54.el7_8.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm |
2.4安装
进入到放rpm包的目录,使用下面命令安装
1 | rpm -ivh --force *.rpm --nodeps |
2.5验证
执行yum命令就能看到熟悉的界面了