The following is an introduction to the solution to the problem that yum cannot be used due to upgrading Python in CentOS 6.4. After all, reinstalling yum is troublesome and may not be feasible. You can use the method introduced in this article to fix it.
1. Check the current system python version
1python -V
2. Download version 2.7.3 of Python
1wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
3. Unzip and install
tar -jxvf Python-2.7.3.tar.bz2
#Enter the decompressed directory
cd Python-2.7.3
#Compile and install
. /configure
make
make install
4. Check whether the installation is successful
/usr/local/bin/python2.7 -V
#If the following information appears, it means the installation is successful.
Python 2.7.3
5. Create soft links
#Under normal circumstances, even after python2.7 is successfully installed, the python pointed to by the system by default is still version 2.6.6. Considering that yum is based on python2.6.6 to work properly, uninstallation is not recommended.
#Use the following method to change the system default python to version 2.7.3
mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/local/bin/python2.7 /usr/bin/python
#Check whether the test is successful
python -V
#The presence of version 2.7.3 information indicates success
Python 2.7.3
6. Solve the problem of yum being unavailable after modifying the system default python version
#Modify yum file
vi /usr/bin/yum
.
#! /usr/bin/python
Change it to the following content
#! /usr/bin/python2.6.6
The entire upgrade process is completed.
7. Other questions
Yum is already available, but I don’t know which expert modified what file in the system, resulting in the error message “no named yum” when using yum. After consulting the information, I learned that they are all versions of python that allow you to modify the head of yum.
But I have already modified it (step 6), and I don’t know how to solve it. Finally, I gave up "Du Niang" and used Google, which is often harmonized, and found a document on the Centos official website. The method is as follows.
First, find the CD or ISO file where you installed Centos, as long as the system version is the same. Copy the following files to the system:
python-2.6.6-36.el6.x86_64.rpm
python-urlgrabber-3.9.1-8.el6.noarch.rpm
python-devel-2.6.6-36.el6.x86_64.rpm
python-libs-2.6.6-36.el6.x86_64.rpm
yum-3.2.29-40.el6.centos.noarch.rpm
The specific version number is based on your system disk or ISO. I copied it to the following directory
/usr/local/src/Python-2.6.6
Execute the installation
cd /usr/local/src/Python-2.6.6/
rpm -Uvh --replacepkgs *.rpm
#The following prompt appears
Preparing.. . ##########################################[100%]
1:python-libs ##########################################[ 20 %]
2:python #########################################[40%]
3:python-urlgrabber #########################################[ 60 %]
4:yum ##########################################[ 80%]
5:python-devel ##########################################[100 %]
Execute the yum command, and the interface you are familiar with appears.