Install Openssl,openssl-devel First
yum install openssl
yum install openssl-devel
1 switch to the specified directory:
Cd/usr/local
2 Download the source tar package
Linux comes with the download tool wget download as follows:
1 |
# wget http://www.python.org/ ftp /python/2.7.9/Python-2.7.9.tgz |
Extract
1 |
tar -xzvf Python-2.7.9.tgz |
Build a folder in/usr/local before compiling Python3 (as a Python installation path to avoid overwriting the old version)
1 |
mkdir /usr/ local /python2 |
Go to the Unpacked folder
Start compiling the installation
1 |
./configure --prefix=/usr/ local /python2 |
The old version is not overwritten at this time, then the original/usr/bin/python link is changed to another name
1 |
mv /usr/bin/python /usr/bin/python_old |
Link to build a new version of Python
1 |
ln -s /usr/ local /python2/bin/python /usr/bin/python |
This time input
The new version of Python will be displayed.
PS: If you do not set up a new installation path Python2, but the direct default installation, the installation of the new Python should be overwritten with the old version of Linux, or may not overwrite, the specific installation process, this can be tested by themselves, of course, if you want to keep the original version, So this is the best way to do it.
Python upgrade steps under Linux