Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Yesterday I accidentally removed the python package using "yum remove" on a CentOS server. After then I realized yum was dependant on python and I could no longer use yum. I think I need to reinstall python to fix the problem. How can I do this without using yum?

share|improve this question

migrated from stackoverflow.com Jul 22 '12 at 15:23

This question came from our site for professional and enthusiast programmers.

    
this is not a programming question –  Ramchandra Apte Jul 22 '12 at 9:35
    
you can compile Python from source if you have a compiler installed and make and autoconfigure –  Ramchandra Apte Jul 22 '12 at 9:37
    
You may find that your question gets better results on ServerFault =) –  katrielalex Jul 22 '12 at 9:58
add comment

3 Answers

I'm surprised you were able to remove the python package. It has so many dependencies on a RHEL/CentOS system, that there's a good chance you removed far more than python. Running yum remove python on one of my CentOS systems yields:

Dependencies Resolved

====================================================================================================================
 Package                                 Arch           Version                             Repository         Size
====================================================================================================================
Removing:
 python                                  x86_64         2.4.3-46.el5                        installed          72 k
Removing for dependencies:
 AcronisAgentLinux                       x86_64         41.0.16-1                           installed          13 M
 BackupAndRecoveryAgent                  x86_64         11.0.17318-1                        installed         154 M
 GConf2                                  i386           2.14.0-9.el5                        installed         4.6 M
 .
 .
 .
 yum-metadata-parser                     x86_64         1.1.2-3.el5.centos                  installed          55 k
 yum-security                            noarch         1.1.16-21.el5.centos                installed          60 k
 yum-updatesd                            noarch         1:0.9-2.el5                         installed          55 k
 yum-utils                               noarch         1.1.16-21.el5.centos                installed         194 k
 zsh                                     x86_64         4.2.6-6.el5                         installed         3.6 M

Transaction Summary
====================================================================================================================
Remove      493 Package(s)
Reinstall     0 Package(s)
Downgrade     0 Package(s)

Is this ok [y/N]: (Heck-no!)

Did you actually let the process remove hundreds of installed packages?

If you only removed a single package, you would need to download the python RPM for your particular version of CentOS. If this was CentOS version 5.8 on 64-bit, for instance, you'd find the current package name in the CentOS repository... Look for python-2.4.3-46.el5.x86_64.rpm

To install that particular package, use wget http://mirror.anl.gov/pub/centos/5.8/os/x86_64/CentOS/python-2.4.3-46.el5.x86_64.rpm to download the individual package. Use rpm -ivh python-2.4.3-46.el5.x86_64.rpm to actually install it with the RPM package manager.

share|improve this answer
    
That surprised me as well. Here is what happened: - I got problems when I tried "yum update", mostly on python packages - I called yum remove python, and then I realized it had so many dependant packages and stopped uninstallation. - After then yum started failing because python was removed - I logged out of the server and couldn't connect ever again using SSH terminal as OpenSSL packages were dependant on python. I'm not a linux admin but I don't think an OS should let you remove python using yum (which is dependant on python). –  umit Jul 26 '12 at 8:35
add comment

If you have make&&gcc installed:

wget http://www.python.org/ftp/python/2.4/Python-2.4.tar.bz2
tar jfvx Python-2.4.tar.bz2
cd python
./configure
make all
make install

Then you can have your Python back.

share|improve this answer
    
Thanks for that but as I lost the access to the server using SSH terminal, I couldn't try this. I ended up reinstalling the OS. –  umit Jul 26 '12 at 8:41
add comment

Building your own Python back didn't work for me. This works:

(note this is for a Centos 6x host, which now uses Python2.6, but it's the same thing)

wget  http://mirror.centos.org/centos/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch
wget  []://mirror.centos.org/centos/6/os/x86_64/Packages/python-devel-2.6.6-51.el6.x86_64.rpm
wget  []://mirror.centos.org/centos/6/os/x86_64/Packages/python-2.6.6-51.el6.x86_64.rpm
wget  []://mirror.centos.org/centos/6/os/x86_64/Packages/python-libs-2.6.6-51.el6.x86_64.rpm

rpm -Uvh --replacepkgs *.rpm

And then Yum will work again.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.