【故障】6、yum不可用
文章目录
- @[toc]
- 一、yum命令不能使用
- 1)报错
- 2)问题分析
- 3)完全删除python及yum重新安装
- 1、删除python
- 2、删除yum
- 3、下载Python依赖rpm包
- 4、下载yum依赖rpm包
- 5、强制安装python
- 6、强制安装yum
- 7、测试
- @[toc]
- 一、yum命令不能使用
- 1)报错
- 2)问题分析
- 3)完全删除python及yum重新安装
- 1、删除python
- 2、删除yum
- 3、下载Python依赖rpm包
- 4、下载yum依赖rpm包
- 5、强制安装python
- 6、强制安装yum
- 7、测试
一、yum命令不能使用
1)报错
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)问题分析
大部分人出现这个错误的原因在于拿到服务器的第一时间发现python版本是2.x,想升级到python3 导致yum损坏,博主花了两个小时查阅资料,最终总算解决问题。
(图片来源网络,侵删)
3)完全删除python及yum重新安装
1、删除python
#删除现有的python [root@test ~]# rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联 [root@test ~]# whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令 [root@test ~]# whereis python ##验证删除,返回无结果
2、删除yum
#删除现有的yum [root@test ~]# rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps [root@test ~]# whereis yum |xargs rm -frv
从中科,163或者阿里云镜像下载相对应的包
centos版本可以根据自己的版本去找对应Packages
如果不知道自己的系统版本,命令行输入这个cat /etc/redhat-release
- 中科: http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/
- 163 : http://mirrors.163.com/centos/7/os/x86_64/Packages/
- 阿里: https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
3、下载Python依赖rpm包
#下载Python安装包 python-libs-2.7.5-48.el7.x86_64.rpm #被python依赖 python-2.7.5-48.el7.x86_64.rpm python-iniparse-0.4-9.el7.noarch.rpm #被yum依赖 python-pycurl-7.19.0-19.el7.x86_64.rpm #被python-urlgrabber依赖 python-urlgrabber-3.10-8.el7.noarch.rpm#被yum依赖 rpm-python-4.11.3-21.el7.x86_64.rpm#被yum依赖
选用阿里地址下载,访问阿地址搜索相关的包
- https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
#下载python包 wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-libs-2.7.5-89.el7.x86_64.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-2.7.5-89.el7.x86_64.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-python-4.11.3-45.el7.x86_64.rpm
4、下载yum依赖rpm包
#yum安装包列表: yum-3.4.3-150.el7.centos.noarch.rpm, 就是它依赖了上面的python库 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm
#下载yum包 mkdir -p yum-rpm/ cd yum-rpm/ wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
5、强制安装python
#强制安装python(--nodeps表示强制) rpm -Uvh python-libs-2.7.5-89.el7.x86_64.rpm --nodeps rpm -Uvh python-2.7.5-89.el7.x86_64.rpm --nodeps rpm -Uvh python-iniparse-0.4-9.el7.noarch.rpm --nodeps rpm -Uvh python-pycurl-7.19.0-19.el7.x86_64rpm --nodeps rpm -Uvh python-urlgrabber-3.10-10.el7.noarch.rpm --nodepsls rpm -Uvh rpm-python-4.11.3-45.el7.x86_64.rpm --nodeps
6、强制安装yum
#强制安装yum(--nodeps表示强制) cd yum-rpm/ rpm -Uvh yum-3.4.3-168.el7.centos.noarch.rpm --nodeps rpm -Uvh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm --nodeps rpm -Uvh yum-plugin-fastestmirror-1.1.31-54.el7_8.narch.rpm --nodeps
7、测试
yum install vim -y
【参考地址】
- https://blog.csdn.net/qq_43238405/article/details/106479937
- https://blog.csdn.net/qq_43238405/article/details/106479937
- https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。