CentOS is self-bringing python. But the version is slightly older. For Python development, be sure to use a new stable version. So, to upgrade Python.
Go to Python main station first download Python source bundle: Python-2.7.6.tar.xz
wget HTTP://WWW.PYTHON.ORG/FTP/PYTHON/2.7.6/PYTHON-2.7.6.TAR.XZ
Installation:
Xz-d PYTHON-2.7.6.TAR.XZ
Tar xvf Python-2.7.6.tar
CD Python-2.7.6
./configure
Make
Make install
Attention:
Before you install Python, it's a good idea to check if GCC is installed. Yum install-y gcc
Otherwise, the/configure stage will be an error.
See Version number:
Run Python, find the version or default, the system comes with version 2.6
To change the system default Python:
Establish a soft connection so that the system default Python points to python2.7
Under normal circumstances, even though the python2.7 installation succeeds, the system is pointing to a python that is still version 2.6, and Yum is based on python2.6 to work correctly. So to point the system's default Python to version 2.7.
#/usr/local/bin/python2.7-v
# Mv/usr/bin/python/usr/bin/python.bak
# ln-s/usr/local/bin/python2.7/usr/bin/python
Run Python, or:
# python-v
Fix Yum Error:
If you hit the Yum command, you'll find an error. You may be prompted that the Python version is incorrect. So we're going to keep Yum still pointing to the old python2.6 version:
Vi/usr/bin/yum
The first line in the open file, which is the line of code that specifies the Python environment, is modified to:
#!/usr/bin/python2.6
Python third-party Package installation location:
/usr/local/lib/python2.7/site-packages/
Centos 6 Installation python2.7.6