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?

  • this is not a programming question Jul 22, 2012 at 9:35
  • you can compile Python from source if you have a compiler installed and make and autoconfigure Jul 22, 2012 at 9:37
  • You may find that your question gets better results on ServerFault =)
    – Katriel
    Jul 22, 2012 at 9:58

3 Answers 3


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
 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.

  • 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, 2012 at 8:35

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.

  • I did have the same kind of incident when porting to Python3 in order to install a Python Webserver on Apache. I discovered that Yum was Python2 only. I have been looking for a wget solution to recover Yum. Thanks AndyD! I am on VM Centos7 though but I guess it shouldn't be an issue. A bit off topic but I am left with a option to install both Python versions in /usr/local directory and to point Python2 to system and Python3 for Apache.
    – user426034
    Jul 19, 2017 at 20:37
  • when i had this issue, wget/curl didnt work either but fortunately scp did
    – zzapper
    Aug 24, 2018 at 10:43

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
make all
make install

Then you can have your Python back.

  • 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, 2012 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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