I installed Python 2.7 and pointed /usr/bin/python to /usr/local/bin/python2.7

After installing Python 2.7, I get the following error message every time I use yum

> sudo yum install setuptools
There was a problem importing one of the Python modules

   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.2 (default, Dec 25 2011, 19:13:04) 
[GCC 4.1.1 20070105 (Red Hat 4.1.1-52)]

If you cannot solve this problem yourself, please go to 
the yum faq at:

How do I get yum working with Python 2.7 on CentOS?


You can edit the yum (/usr/bin/yum) call to python like:


Make a backup first ;-)

| improve this answer | |

Quite simply - don't point /usr/bin/python to any other python. Instead, if you want to use python2.7 just modify your path to put /usr/local/bin first.

In general, you shouldn't touch anything in /usr/{bin,lib...} other than in /usr/local

| improve this answer | |

this why you made installation to a new version of python than the one that was already installed with your OS and that yum is dependent on.

simply you have to edit usr/bin/yum and change the shebang to the same version installed within your distribution. change


to specific version

#!/usr/bin/python2.6 (in my os)
| improve this answer | |

You can build python2.7 (as described in http://docs.python.org/devguide/setup.html#unix ) instead of using yum to install it. This involves downloading the source and following the directions found in the README. When you get to the point where you would normally run 'make install', you want to run 'make altinstall'. This will leave default python in place and give a python2.7 command in /usr/local/bin/ instead.



| improve this answer | |

You don't get yum working with Python 2.7. Instead, you need to have to have 2.7 installed too, but leave 2.4 where it is to avoid breaking e.g. yum.

Alfred Chiesa wrote a guide walking through this process. Check it out and see if that can help you accomplish what you need.

| improve this answer | |

Your Answer

