问题大致如下: No module named yum Please install a package which provides this module, or It’s possible that the above module doesn’t match the 错误原因:你现在安装的python跟yum所依赖的python不相符,请安装相对应的python。 方案一:更换软链接 方案二:更换yum头(此方法同一,好处是你将python3设置软链接之后yum也可以用) 在某度查了几篇文章发现都是这个方法,你们可以试试,我想应该没什么用。 方案三:完全删除python及yum重新安装 从中科,163或者阿里云镜像下载相对应的包 centos版本可以根据自己的版本去找对应Packages 中科: https://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/ Python跟yum的安装包根据时间的变化版本也会变动,以下版本为2018.06.12使用,最新版本根据文件的前缀自行下载。 下载大家都会吧,用wget下载到服务器上,下载好了之后一定要按照上面的顺序依次安装。 yum安装也按照顺序执行,在执行第一个rpm时, 结尾加上 –nodeps参数强制安装 修复yum报错问题之后,如果还想安装python3.x 以及 pip3 请看此篇文章:Linux下 python2.x与python3.x共存 点个关注再走呗~
忙碌了两个小时的陈师傅,决定发一篇博客以防其他网友继续撞坑!!!
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
verify that the module is installed correctly.
current version of Python, which is:大部分人出现这个错误的原因在于拿到服务器的第一时间发现python版本是2.x,想升级到python3 导致yum损坏,博主花了两个小时查阅资料,最终总算解决问题。
root@local:[/root] whereis python //寻找python所有路径 python: /usr/bin/python /usr/bin/python2.7 /usr/bin/python.bak /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /usr/share/man/man1/python.1.gz
root@local:[/usr/bin] mv python python.bak //备份的好习惯一定不能忘 root@local:[/usr/bin] ln -s /usr/bin/python2.7 /usr/bin/python //将python2.7软链接
root@local:[/usr/bin] python -V Python 2.7.5 //还原python默认版本
root@local:[/usr/bin] python2.7 Python 2.7.5 (default, Apr 2 2020, 13:16:51) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
如果没有任何反应,那么此版本即为yum所依赖的版本,如果出现错误,那么只需要另换2.x继续重复此操作,最终找到对应版本即可(如果此方法无效,直接看方案三)。
找到yum文件,编辑此文件root@local:[/root] which yum /usr/bin/yum root@local:[/root] vi /usr/bin/yum 将第一行的#!/usr/bin/python 改成 #!/usr/bin/python2.x
[root@test ~]# rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联 [root@test ~]# whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令 [root@test ~]# whereis python ##验证删除,返回无结果
[root@test ~]# rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps [root@test ~]# whereis yum |xargs rm -frv
如果不知道自己的系统版本,命令行输入这个cat /etc/redhat-release
163 : https://mirrors.163.com/centos/7/os/x86_64/Packages/
阿里: https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
我们需要下载的rpm文件列表:
链接:https://www.jianshu.com/p/89df82a5d74b
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
安装命令rpm -ivh xxx.rpm
yum安装包列表:
链接:https://www.jianshu.com/p/89df82a5d74b
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
此处图片转载自@有人敲门knocky最后大功告成!!!
root@local:[/usr/bin] yum *************************** You need to give some command Usage: yum [options] COMMAND List of Commands: check Check for problems in the rpmdb check-update Check for available package updates clean Remove cached data deplist List a package's dependencies distribution-synchronization Synchronize installed packages to the latest available versions downgrade downgrade a package erase Remove a package or packages from your system fs Acts on the filesystem data of the host, mainly for removing docs/lanuages for minimal hosts. fssnapshot Creates filesystem snapshots, or lists/deletes current snapshots. groups Display, or use, the groups information help Display a helpful usage message history Display, or use, the transaction history info Display details about a package or group of packages install Install a package or packages on your system list List a package or groups of packages load-transaction load a saved transaction from filename makecache Generate the metadata cache provides Find what package provides the given value reinstall reinstall a package repo-pkgs Treat a repo. as a group of packages, so we can install/remove all of them repolist Display the configured software repositories search Search package details for the given string shell Run an interactive yum shell swap Simple way to swap packages, instead of using shell update Update a package or packages on your system update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system updateinfo Acts on repository update information upgrade Update packages taking obsoletes into account version Display a version for the machine and/or available repos.
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算