Reprinted from Http://blog.163.com/[email protected]/blog/static/164767406201221614650717/
Since the CentOS Yum is developed using the python2.4.x, it does not support a later version of Python installation, so a manual installation is required.
Install the dependency package first, run the following command
Yum install-y gcc make
Yum install-y libxml2
Yum Install-y libxslt
Yum install-y pkgconfig Zlib-devel
Yum Install-y libgcrypt-devel
#备份文件/usr/bin/python (be sure to back up or Yum will not run after the installation is complete)
mkdir ~/tmp
Cp/usr/bin/python ~/tmp
Execute the following command to download and install Python:
wget http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tgz
Tar zxvf python-2.7.1.tgz
CD Python-2.7.1
./configure--prefix=/usr/lib/python2.7--with-threads--enable-shared
Make;make Install
Cp/usr/lib/python2.7/bin/python/usr/bin/python
cp/usr/lib/python2.7/bin/python2.7/usr/bin/
cp/usr/lib/python2.7/lib/libpython2.7.so.1.0/usr/lib/
This python2.7.1 installation is complete.
However, if you run Yum,yum now there will be a run-time error because Yum only supports the python2.4.x version
The previously backed up Python file needs to be overwritten to/usr/bin/python2.4 (python2.4 also becomes the python2.7 version when I install it) so just in case the following command is executed, copy the backup Python to the/usr/bin/ python2.4
CP ~/tmp/python/usr/bin/python2.4
Modify/usr/bin/yum
Vi/usr/bin/yum
The first line of the
#!/usr/bin/python
Revision changed to
#!/usr/bin/python2.4
Then save, yum fix.
Installation of python2.7.1 under CentOS and the problem of Yum not available after loading