CentOS 6 upgrade Default Python version

Source: Internet
Author: User

CentOS 6 is a relatively stable version of Linux server that has been running for many years in production environments in a number of enterprises. However, the original version of Python in CentOS 6 is still 2.6, and is typically developed using python2.7 during development. python2.7 is the last 2.x version supported by Python, and it is a full and stable version of the feature. Most developers who do not turn to Python3 now use the python2.7 version.

Because old python in CentOS has been deeply dependent on the system, uninstalling the original Python will cause some software anomalies in the system, so it cannot be uninstalled. What if you want to use a different version of Python? The best way is to install a new version.

This article briefly summarizes the process of upgrading the python2.6.6 version to 2.7.14 in CentOS6.8.

    1. Download Python source code.
      Address: https://www.python.org/downloads/release/python-2714/

    2. Unzip and install.
      TAR-ZXVF python-2.7.14.tar.gz
      CD Python-2.7.14
      ./configure--prefix=/usr/local/python2.7
      Make
      Make install

    3. If there is no error in the previous step, you can enter this step to create a python executable file soft link. If you don't want to overwrite the Python executable file of the original python2.6, you can create a soft link called python2.6, and then create a soft link for the python2.7.
      Ln-s/usr/local/python2.7/bin/python2.7//usr/bin/python

    4. Now you can look at the Python version.
      Python-v

    5. Since the Yum tool in CentOS uses python2.6 and can only use it, when we modify the default interpreter for the Python command, Python is redirected to python2.7. Yum is then used to give an error, so the Yum Python interpreter is specifically designated as python2.6.
      Vim/usr/bin/yum
      Modify the "#!/usr/bin/python" of the first line to the original Python version location of the system:
      #!/usr/bin/python2.6

CentOS 6 upgrade Default Python version

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.