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