Installing Python 2.7 broke "yum"
Solution 1
You can edit the yum (/usr/bin/yum) call to python like:
#!/usr/bin/python2.4
Make a backup first ;-)
Solution 2
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
#!/usr/bin/python
to specific version
#!/usr/bin/python2.6 (in my os)
Solution 3
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
Solution 4
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.
From the Python 2.7 README: "On Unix and Mac systems if you intend to install multiple versions of Python using the same installation prefix (--prefix argument to the configure script) you must take care that your primary python executable is not overwritten by the installation of a different version. All files and directories installed using "make altinstall" contain the major and minor version and can thus live side-by-side. "make install" also creates ${prefix}/bin/python which refers to ${prefix}/bin/pythonX.Y. If you intend to install multiple versions using the same prefix you must decide which version (if any) is your "primary" version. Install that version using "make install". Install all other versions using "make altinstall".
For example, if you want to install Python 2.5, 2.6 and 3.0 with 2.6 being the primary version, you would execute "make install" in your 2.6 build directory and "make altinstall" in the others."
Solution 5
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.
Related videos on Youtube
user965363
Updated on September 18, 2022Comments
-
user965363 over 1 year
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 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.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: http://wiki.linux.duke.edu/YumFaq
How do I get
yum
working with Python 2.7 on CentOS?