正在加载...

No module named rpm

[ 2010/07/05 17:52 | by selboo ]

想用yum 安装一个包,发现yum不能使用如下。

[root@done1 yum]# yum
There was a problem import[separator]ing 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.5.2 (r252:60911, Jul  2 2010, 11:08:48)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://wiki.linux.duke.edu/YumFaq


查看yum 脚本
[root@done1 yum]# which yum
/usr/bin/yum
[root@done1 yum]# cat /usr/bin/yum
#!/usr/bin/python
import sys
try:
    import yum
except ImportError:
    print >> sys.stderr, """\
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   %s

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:
%s

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://wiki.linux.duke.edu/YumFaq
  
""" % (sys.exc_value, sys.version)
    sys.exit(1)

sys.path.insert(0, '/usr/share/yum-cli')
try:
    import yummain
    yummain.user_main(sys.argv[1:], exit_code=True)
except KeyboardInterrupt, e:
    print >> sys.stderr, "\n\nExiting on user cancel."
    sys.exit(1)
[root@done1 yum]# python
Python 2.5.2 (r252:60911, Jul  2 2010, 11:08:48)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import yum
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/python2.5/lib/python2.5/site-packages/yum/__init__.py", line 23, in <module>
    import rpm
ImportError: No module named rpm
>>> import yummain
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named yummain
>>>


从脚本里查看,加载了yum 和 yummain 模块错误

[root@done1 yum]# ls /usr/local/python2.5/lib/python2.5/site-packages/yum/
ls: /usr/local/python2.5/lib/python2.5/site-packages/yum/: No such file or directory
[root@done1 yum]# python -V
Python 2.5.2


后来得知 redhat yum 必须在 python2.4下才能运行


[root@done1 yum]# ll /usr/bin/python
lrwxrwxrwx 1 root root 34 Jul  5 17:40 /usr/bin/python -> /usr/local/python2.5/bin/python2.5
[root@done1 yum]# rm -rf /usr/bin/python
[root@done1 yum]# ln -s /usr/bin/python2.4 /usr/bin/python


yum命令正常
最后编辑: selboo 编辑于2010/07/05 18:13
Tags: ,
,
发表评论
表情
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]