When you ran yum remove python
on your CentOS 6 system, you essentially broke the package management system itself. YUM is written in Python and depends on Python 2.6 for its core functionality. Here's why this happens:
# rpm -q --requires yum | grep python
python >= 2.6
python(abi) = 2.6
python-iniparse
python-urlgrabber
python-libs
python-sqlite
The error message you're seeing suggests Python is still present but likely corrupted. Let's check deeper:
# rpm -V python
missing /usr/bin/python
missing /usr/bin/python2
This verification shows critical files are missing despite RPM believing Python is installed.
Here's the step-by-step solution to restore your system:
# wget http://vault.centos.org/6.10/os/x86_64/Packages/python-2.6.6-68.el6.x86_64.rpm
# wget http://vault.centos.org/6.10/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
# rpm -ivh --replacepkgs --replacefiles python-2.6.6-68.el6.x86_64.rpm
# rpm -ivh --replacepkgs --replacefiles yum-3.2.29-81.el6.centos.noarch.rpm
If the above doesn't work, try forcing the installation:
# rpm -ivh --force --nodeps python-2.6.6-68.el6.x86_64.rpm
# rpm -ivh --force --nodeps yum-3.2.29-81.el6.centos.noarch.rpm
After reinstalling, verify everything works:
# python -V
Python 2.6.6
# yum list installed | grep python
python.x86_64 2.6.6-68.el6 @base
To safely install Python 2.7 without breaking YUM:
# yum install centos-release-scl
# yum install python27
# scl enable python27 bash
This keeps system Python 2.6 intact while giving you access to Python 2.7 via Software Collections.
When working with CentOS 6 systems, one of the most dangerous commands you can accidentally run is:
yum remove python
This nukes not just Python but also YUM itself since the package manager depends on Python. Suddenly, you're left with:
-bash: yum: command not found
The RPM database thinks Python is still installed (as shown by the package conflict message), but critical symlinks and dependencies are broken. Here's what you'll typically see:
$ ls -la /usr/bin/python*
lrwxrwxrwx 1 root root 6 Dec 4 20:31 python2 -> python
-rwxr-xr-x 2 root root 4864 Nov 12 2010 python2.6
-rwxr-xr-x 2 root root 4864 Nov 12 2010 python;4edbd894
First, download the Python RPM manually:
wget http://vault.centos.org/6.0/os/x86_64/Packages/python-2.6.5-3.el6.x86_64.rpm
Then force reinstall it with RPM:
rpm -iv --replacepkgs --replacefiles python-2.6.5-3.el6.x86_64.rpm
After successful reinstallation, verify both Python and YUM are working:
python -V
yum --version
For Python 2.7 installation on CentOS 6, always use alternatives:
yum install python27 -y
update-alternatives --config python
If the above fails, you'll need to manually install YUM dependencies:
rpm -ivh http://vault.centos.org/6.0/os/x86_64/Packages/yum-3.2.29-40.el6.noarch.rpm \
http://vault.centos.org/6.0/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm \
http://vault.centos.org/6.0/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm