Objective:
The CENTOS 6.X series is installed by default Python 2.6, the current development is mainly using Python 2.7, there are many differences between the two versions, the program under Python 2.6 often problems.
For example: The Re.sub function, 2.7 supports the flags parameter, while 2.6 does not support it. So, to install Python 2.7来 run the Flask application, but 2.6 cannot be deleted because the system is dependent on it.
1. Install GCC Firstuse the following command
Yum Install gcc gcc-c++
2. Download Python-2.7.8.tar file
https://www.python.org/ftp/python/2.7.8/
3. Unzip the tar file
TAR-XZVF Python-2.7.8.tar
4.CD python-2.7.8
./configure--prefix=/usr/local/python # # # Note: Install in a new directory, prevent overwriting the system by default installation of Python make do install
5. Establish a soft connection, so that the system default Python point to python-2.7.8 after the installation is complete, to replace the system comes with Python, but CentOS Yum relies on Python work, in order to ensure the normal operation of Yum, we have to replace, before Rename your own Python backup first, by following the steps below:
mv/usr/bin/python/usr/bin/python-2.6.6 ln-s/usr/local/python/bin/python/usr/bin/python
Now that you have installed all of the Python installation or upgrade, let's take a look at the current Python version:
python-v
Python 2.7.8
Although Python is now installed, there is a problem with the Yum command--yum does not work properly, so take the following steps
6. To modify Yum, run it to the old version:
Vi/usr/bin/yum
The "#!/usr/bin/python" in the first line
Modify to "#!/usr/bin/python-2.6.6", Save can
CentOS6.5 Installing Python