centos6.4 under compile and install python2.7

Source: Internet
Author: User

1, prepare

CentOS comes with Python, so it can be executed directly under the shell: Python

can see the corresponding printing information, but the system comes with a python version is too old, so you should recompile a new version of Python.

However, it is best not to overwrite the original system with Python, in case the system appears inexplicable problems, you can compile the new version of Python into a specified directory, so the best!

2, download a new version of Python (2.7.8)

Address: https://www.python.org/downloads/source/

Extract:

xz-d python-2.7.8.tar.xz---decompression. XZ

TAR-XVF Python-2.7.8.tar---unzip. tar

3, installation

CD Python-2.7.8

./configure--prefix=/usr/local/python27

If it is an error, please install the dependent package of the corresponding defect, and then proceed to execute the instruction!

Make && make install

Wait for the installation to complete before executing:

/usr/local/python27/bin/python

You can see the Python print out the information that shows the Python version is the new version we installed!

The script can now be connected to the/usr/bin directory so that it can be started directly in the shell and executed:

Ln-s/usr/local/python27/bin/python/usr/bin/python27

Then execute directly in the shell: python27

As you can see, the printed information is our latest version of Python installed!

3. Run a python file

To switch directories to the home directory, create a new Python folder in which a suffix named:. py

File and enter the following code:

#!/usr/bin/python27

Import Platform

Print Platform.uname ()

Then save the file to exit, add executable permissions to the file after execution:./file name

You can see the information!

At this point, complete!







centos6.4 the installation python2.7

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.