Python – How to completely remove and re-install python (without yum)

centos5package-managementpythonreinstall

I have a corrupted / missing installation of Python on a CentOS 5 server, and yum won't help me reinstall because python is a dependency. When I try installing python-2.4.3-44.el5.x86_64 from the rpm, it informs me that python-libs is required.

But when I try to install python-libs:

[root@myserver]# rpm -ivh http://mirror.centos.org/centos/5/os/x86_64/CentOS/python-libs-2.4.3-44.el5.x86_64.rpm

error: Failed dependencies:
        python(abi) = 2.4 is needed by python-libs-2.4.3-44.el5.x86_64

At this point, I would like to purge any remnants of the old installation from my system, and do a completely clean installation. However, I'm unclear on how to completely remove python, and I haven't been able to find a pythonabi or python-abi package that matches up with version 2.4.3-44.el5.

How should I approach this problem?

Best Answer

Probably what I'd do is first find all the easily identifiable python packages:

 rpm -qa | grep python

Then erase them using

 rpm --erase pkg1 ... pkgn

If there are dependencies flagged, then if you can include these in the packages to be deleted.

You CAN override the dependency checks by including the

 --nodeps

flag after the --erase flag on the rpm command line. Not always recommended of course but sometimes necessary.

Then with all the packages downloaded from what ever source you have you then do:

 rpm --install pkg1 ... pkgn

Again, if possible satisfy all the dependencies. But you can override this behavior using the:

 --nodeps --force

flags after the --install flag. Again, not always recommended but sometimes necessary.