Centos updates python 2.7.3

  • 2020-04-02 13:48:54
  • OfStack

First, download the source tar package

Linux download tool wget can be downloaded as follows:


wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz

Download after the completion of the download directory, decompression


tar -zxvf Python-2.7.3.tgz

Go to the unzipped folder


cd Python-2.7.3

Create a folder named python27 in /usr/local before compiling (as the python installation path to avoid overwriting older versions)


mkdir /usr/local/python2.7.3

Compile the installation in the unzipped directory


./configure --prefix=/usr/local/python2.7.3
make
make install

Instead of overwriting the old version, change the original /usr/bin/python link to something else


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

This is the time to type in

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 linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

Related articles: