一、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、测试
【参考地点】
- https://blog.csdn.net/qq_43238405/article/details/106479937
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |