CentOS6.5 Installing Python

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.