Centos 6 Installation python2.7.6

Source: Internet
Author: User

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

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.