Yum not working?

Nuwan Indika picture Nuwan Indika · May 11, 2014 · Viewed 58.6k times · Source

I have default python 2.7 and i try to install python3.3 and install pip3 and Django.now when i try to install others using yum i got this error.for a example yum update

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.7.5 (default, Nov 12 2013, 16:18:42) [GCC 4.8.2 20131017 (Red Hat 4.8.2-1)] If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq

How can i fix this error?

Answer

John Smith Optional picture John Smith Optional · May 11, 2014

There is probably many python versions on your system and only one of them has the yum library installed. For some reason the python binary called when you run yum on the command line is not the one who has the yum library installed.

Find the list of python 2 binaries available on your system. Run as root:

find / -type f -executable -name 'python2*'

The output will probably look like that:

/usr/bin/python2.6
/usr/bin/python2.7
...

etc...

For each one of these, run

/usr/bin/python2.x

You'll get a python prompt. Run:

>>> import yum

Do this for every python binary until you find one that doesn't raise an ImportError at this step.

Then find out what is the path that yum is using to run python. This is the first line in the yum script. Run

cat `which yum` | head -1

You'll probably get:

#!/usr/bin/python

Now, run as root:

ln -s /usr/bin/python2.x /usr/bin/python 

(replace python2.x with the good python version you found earlier).