How to properly upgrade Python under CentOS

Source: Internet
Author: User

When setting up a test environment on CentOS, when you encounter the need to upgrade the Python version, the entire upgrade process is documented:

The Python version that comes with CentOS5 is 2.4, but many Python-based applications now require a Python version higher than 2.4. When upgrading the Python version, you must not uninstall the Python 2.4and install python2.7, which may cause many programs to fail, even connect to the network, and finally have to reinstall the system. The conservative approach is to install python2.7 's source package directly, which is Python's two-version coexistence. (because there are many programs in CentOS that rely on Python, it's best not to try to uninstall python2.4).

(1) Download/install Python

Download python2.7.2.tar.bz2 (http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2)

$tar JXVF python2.7.2.tar.bz2 $CD Python2.7.2

$./configure $make && make install

Since then, the python2.7 installation path defaults to the/usr/local/lib/python2.7

To view the Python version:

$/usr/local/bin/python2.7-v

(2) Establish a soft connection so that the system default Python points to python2.7

Under normal circumstances, even if the python2.7 installation succeeds, the system will point to Python is still version 2.4, considering that Yum is based on python2.4 to work properly, not easy to uninstall. How do you point to the system default Python to version 2.7?

Mv/usr/bin/python/usr/bin/python.bak (or Rm-rf/usr/bin/python)

Ln-s/usr/local/bin/python2.7/usr/bin/python

Verify that the Python point is successful python-v

(3) Fix system python soft link to python2.7 version, Yum does not work properly

Method:

$vi/usr/bin/yum Change the text editing display #/usr/bin/python to #/usr/bin/python2.4, save the changes.

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.