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).