/usr/bin/python (Python 2.4) was deleted on CentOS 5. I compiled from source but yum is still broken. How can I get everything back to the way it was?

Maxwell asked:

I saw a lot of other questions like this but none of them answered the exact part I am having trouble with (actually installing the Python RPM). Someone on my system deleted /usr/bin/python and /usr/bin/python2.4 on my 64 bit CentOS 5.8 installation. I recompiled Python 2.4 from source, but now whenever I try to yum install anything I get the following error:

[root@cerulean-OW1 ~]# yum install httpd
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.4 (#1, Dec 16 2012, 09:16:56)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://wiki.linux.duke.edu/YumFaq

I checked http://wiki.linux.duke.edu/YumFaq and it said the following:

If you are getting a message that yum itself is the missing module then you probably installed it incorreclty (or installed the source rpm using make/make install). If possible, find a prebuilt rpm that will work for your system like one from Fedora or CentOS. Or, you can download the srpm and do a

rpmbuild --rebuild yum*.src.rpm 

I tried going to http://rpm.pbone.net/index.php3/stat/4/idpl/17838875/dir/centos_5/com/python-2.4.3-46.el5.x86_64.rpm.html to install Python, which resulted in the following error:

[root@cerulean-OW1 ~]# rpm -Uvh python-2.4.3-46.el5.x86_64.rpm                  
error: Failed dependencies:
    python-libs-x86_64 = 2.4.3-46.el5 is needed by python-2.4.3-46.el5.x86_64

So I tried installing python-libs-x86_64, which resulted in the following:

[root@cerulean-OW1 ~]# rpm -Uvh python-libs-2.4.3-46.el5_8.2.x86_64.rpm
warning: python-libs-2.4.3-46.el5_8.2.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 192a7d7d
Preparing...                ########################################### [100%]
        package python-libs-2.4.3-46.el5_8.2.x86_64 is already installed
        file /usr/lib64/libpython2.4.so.1.0 from install of python-libs-2.4.3-46.el5_8.2.x86_64 conflicts with file from package python-libs-2.4.3-46.el5_8.2.x86_64

My answer:


Use the --replacefiles --replacepkgs and --nodeps options to RPM to force reinstallation of these packages:

rpm --replacefiles --replacepkgs --nodeps -ivh python-libs-2.4.3-46.el5_8.2.x86_64.rpm python-2.4.3-46.el5.x86_64.rpm 

Once python is in a semi-working state again, you should use yum distro-sync to get the current versions of your system packages installed, if these happen to not be current.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.