CentOS 6.* 运行yum报错:No module named rpm

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS 6.* 运行yum报错:No module named rpm相关的知识,希望对你有一定的参考价值。

1. 使用yum安装软件时,报如下错误:

[[email protected] ~]# yum install lrzsz    
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   No module named rpm

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.6.6 (r266:84292, Jul 23 2015, 15:22:56) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)]

If you cannot solve this problem yourself, please go to 
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

[[email protected] ~]# 

2. 查看yum指向的python是否为2.6.6

[[email protected] ~]# head -1 /usr/bin/yum
#!/usr/bin/python2.6
[[email protected] ~]# ll /usr/bin/python2.6
-rwxr-xr-x 1 root root 4864 7月  24 2015 /usr/bin/python2.6
[[email protected] ~]# /usr/bin/python2.6 --version
Python 2.6.6
[[email protected] ~]# 

3. 如果yum不是指向python2.6.6:

修改yum指向到python2.6.6

[[email protected] ~]# vim /usr/bin/yum

# 测试
[[email protected] ~]# yum install lrzsz

4. 如果yum指向的是2.6.6:

则说明centos6.*的python2.6.6损坏,通过rpm重装python2.6.6,须到官网下载指定版本的包:
官网:http://vault.centos.org/6.8/os/x86_64/Packages/

需下载的包:

python
python-iniparse
python-pycurl
python-urlgrabber
python-devel
python-libs
python-setuptools
rpm-python

安装下载的rpm包:

[[email protected] ~]# rpm -ivh *rpm

# 测试yum是否可用
[[email protected] ~]# yum install lrzsz

5. 如果yum不可用,重装yum包。

# 需下载的包:
yum 
yum-metadata-parser 
yum-utils 
yum-plugin-fastestmirror 
yum-plugin-protectbase 
yum-plugin-aliases 
yum-plugin-downloadonly

# 安装
rpm -ivh yum*

# 测试
[[email protected] ~]# yum install lrzsz

以上是关于CentOS 6.* 运行yum报错:No module named rpm的主要内容,如果未能解决你的问题,请参考以下文章

centos 系统服务器yum源报错 “No module named yum”

python的卸载方式和运行yum报错:No module named yum

Centos7 执行firewall-cmd报错“ModuleNotFoundError: No module named 'gi'”

centos7容器运行报错/etc/rc.d/init.d/functions: No such file or directory

centos7容器运行报错/etc/rc.d/init.d/functions: No such file or directory

使用 mod_wsgi 在 Centos 6.5 上部署基于 python3.4 的 Django 项目:可行吗?