To compile and install the Python2.7.8 version in CentOS

Source: Internet
Author: User
Tags first row centos

Whim, want to learn python, I heard it is good to do reptiles. Starting with the running environment, Python is already built into the CentOS, but the version seems older and the version is 2.4.3 through the PYTHON-V command. The current version of Python 2.x is 2.7.8, so start to upgrade.

First, download the source package, which commands the following:

wget--no-check-certificate https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz

Here you need to pay special attention, because the download URL is the beginning of HTTPS, so the wget command to add--no-check-certificate parameters.

After downloading the good source package, decompression:

TAR-ZXVF./python-2.7.8.tgz

After extracting the directory of Python-2.7.8, we started compiling the source code:


CD Python-2.7.8
./configure--prefix=/usr/local/python
Make
Make install

After compiling the installation, to replace the system from the Python, but CentOS Yum rely on Python work, in order to ensure the normal operation of the Yum, we need to replace, before the replacement, the Python renamed to Backup, the following methods:


mv/usr/bin/python/usr/bin/python-2.4.3
Ln-s/usr/local/python/bin/python/usr/bin/python

Once the above two lines have been executed, you can verify the success of the deployment by using "Python-v" and "/usr/bin/python-2.4.3-v" respectively, and the correct result should be 2.7.8 and 2.4.3.

Finally, to modify the Yum to run to the old version:

Vi/usr/bin/yum

Modify the "#!/usr/bin/python" in the first row to "#!/usr/bin/python-2.4.3" and save

Related Article

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.