no module named rpm - when i call yum on shell

情到浓时终转凉″ 提交于 2019-12-22 17:54:15

问题


I installed python 2.7.5 and mod_wsgi on centos machine linux os. And this happened:

# yum
Error processing line 1 of /usr/local/lib/python2.7/site-packages/abrt.pth:

  Traceback (most recent call last):
    File "/usr/local/lib/python2.7/site.py", line 152, in addpackage
      exec line
    File "<string>", line 1, in <module>
  ImportError: No module named abrt_exception_handler

Remainder of file ignored
Traceback (most recent call last):
  File "/usr/bin/yum", line 22, in <module>
    import yummain
  File "/usr/share/yum/yummain.py", line 22, in <module>
    import clientStuff
  File "/usr/share/yum/clientStuff.py", line 18, in <module>
    import rpm
ImportError: No module named rpm

yum module doesn't run because of rpm module doesnt exist. I don't know how can I install the python-rpm module and will it work if I install it?

Thanks.


回答1:


You shouldn't touch your system's python installation. Updating the sysem's python version should be left to the distirbution.

If you need a newer version then install it, but keep it separate form the system version.

You should restore the original /usr/bin/python - it usually is a symlink (in this case to /usr/bin/python2.6.

You'll probably want to remove and reinstall python2.7, as copying modules (specially if they contain binary extensions) from one version to another can lead to problems. Install the packages you need directly using the new python version:

python2.7 setup.py ...

If you want mod_wsgi to use the newer version, use the WSGIPythonHome directive to point it to the right prefix (/usr/local).




回答2:


I had similar problem, what I did is to manually download the old version python and reinstall it with rpm:

$ rpm -qa | grep python- | grep 2.6
$ sudo rpm -ivh --force ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/6.5/x86_64/updates/fastbugs/python-2.6.6-52.el6.x86_64.rpm

After the reinstallation of python, my yum works correctly.



来源:https://stackoverflow.com/questions/17490921/no-module-named-rpm-when-i-call-yum-on-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!