ToB企服应用市场:ToB评测及商务社交产业平台

标题: 【故障】6、yum不可用 [打印本页]

作者: 老婆出轨    时间: 2024-8-24 22:37
标题: 【故障】6、yum不可用
  

一、yum下令不能利用

1)报错

  1. There was a problem importing one of the Python modules
  2. required to run yum. The error leading to this problem was:
  3. No module named yum
  4. Please install a package which provides this module, or
  5. verify that the module is installed correctly.
  6. It’s possible that the above module doesn’t match the
  7. current version of Python, which is:
复制代码
2)问题分析

大部分人出现这个错误的缘故起因在于拿到服务器的第一时间发现python版本是2.x,想升级到python3 导致yum粉碎,博主花了两个小时查阅资料,终极总算解决问题。
3)完全删除python及yum重新安装

1、删除python

  1. #删除现有的python
  2. [root@test ~]# rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联
  3. [root@test ~]# whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
  4. [root@test ~]# whereis python ##验证删除,返回无结果
复制代码
2、删除yum

  1. #删除现有的yum
  2. [root@test ~]# rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
  3. [root@test ~]# whereis yum |xargs rm -frv
复制代码
从中科,163或者阿里云镜像下载相对应的包
centos版本可以根据本身的版本去找对应Packages
如果不知道本身的体系版本,下令行输入这个cat /etc/redhat-release

3、下载Python依赖rpm包

  1. #下载Python安装包
  2. python-libs-2.7.5-48.el7.x86_64.rpm #被python依赖
  3. python-2.7.5-48.el7.x86_64.rpm
  4. python-iniparse-0.4-9.el7.noarch.rpm #被yum依赖
  5. python-pycurl-7.19.0-19.el7.x86_64.rpm #被python-urlgrabber依赖
  6. python-urlgrabber-3.10-8.el7.noarch.rpm#被yum依赖
  7. rpm-python-4.11.3-21.el7.x86_64.rpm#被yum依赖
复制代码
选用阿里地点下载,访问阿地点搜索干系的包

  1. #下载python包
  2. wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-libs-2.7.5-89.el7.x86_64.rpm
  3. wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-2.7.5-89.el7.x86_64.rpm
  4. wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
  5. wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
  6. wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
  7. wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-python-4.11.3-45.el7.x86_64.rpm
复制代码
4、下载yum依赖rpm包

  1. #yum安装包列表:
  2. yum-3.4.3-150.el7.centos.noarch.rpm, 就是它依赖了上面的python库
  3. yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
  4. yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm
复制代码
  1. #下载yum包
  2. mkdir -p yum-rpm/
  3. cd  yum-rpm/
  4. wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
  5. wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
  6. wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
复制代码
5、欺压安装python

  1. #强制安装python(--nodeps表示强制)
  2. rpm -Uvh python-libs-2.7.5-89.el7.x86_64.rpm --nodeps
  3. rpm -Uvh python-2.7.5-89.el7.x86_64.rpm --nodeps
  4. rpm -Uvh python-iniparse-0.4-9.el7.noarch.rpm --nodeps
  5. rpm -Uvh python-pycurl-7.19.0-19.el7.x86_64rpm --nodeps
  6. rpm -Uvh python-urlgrabber-3.10-10.el7.noarch.rpm --nodepsls
  7. rpm -Uvh rpm-python-4.11.3-45.el7.x86_64.rpm --nodeps
复制代码
6、欺压安装yum

  1. #强制安装yum(--nodeps表示强制)
  2. cd yum-rpm/
  3. rpm -Uvh yum-3.4.3-168.el7.centos.noarch.rpm --nodeps
  4. rpm -Uvh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm --nodeps
  5. rpm -Uvh yum-plugin-fastestmirror-1.1.31-54.el7_8.narch.rpm --nodeps
复制代码
7、测试

  1. yum install vim -y
复制代码
【参考地点】



免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4