First download the source tar package
You can use the built-in linux download tool wget to download, as shown below:
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
After the download is complete, go to the download directory and decompress the package.
tar -zxvf Python-2.7.3.tgz
Enter the decompressed folder
cd Python-2.7.3
Create a folder python27 in/usr/local before compilation (as the python installation path to avoid overwriting the old version)
mkdir /usr/local/python2.7.3
Compile and install the package in the decompressed directory
./configure --prefix=/usr/local/python2.7.3makemake install
In this case, the old version is not overwritten, and the original/usr/bin/python link is changed to another name.
mv /usr/bin/python /usr/bin/python_old
Create a link to the new version of python.
ln -s /usr/local/python2.7.3/bin/python2.7 /usr/bin/python
ln -s /usr/local/python2.7.3/bin/python2.7 /usr/bin/python2.7
Enter
python
The new version of python is displayed.
Python 2.7.3 (default, Sep 29 2013, 11:05:02)[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>>