Steps to update the Python version under CentOS

Source: Internet
Author: User

Reprint: After installing CentOS5.9 (Final), execute #python and #python-v, See version number is 2.4.3, very old, and previously written are running in python3.x above, 3.X and 2.X have a lot of different, interested friends can refer to this article after the installation of CentOS5.9 (Final), the implementation of #python and #python-v, See version number is 2.4.3, very old, and previously written are running on python3.x above, 3.X and 2.X have a lot of different, interested friends can refer to this article:

Http://www.jb51.net/article/34011.htm

Update Python never remove the old version! The old and new versions can coexist, and many of the basic commands and packages are dependent on the preinstalled versions of Python, such as Yum.

Update Python:

1th step: Update gcc because the GCC version is too old to cause the new version of Python package compilation to be unsuccessful

Copy CodeThe code is as follows:
#yum-y Install gcc

The system is automatically downloaded and installed or updated, and so it ends itself

2nd step: Download the Python-3.3.0 package

Copy CodeThe code is as follows:
#wget http://python.org/ftp/python/3.3.0/Python-3.3.0.tar.bz2

Note: The package downloaded according to the above command will be stored in your current working directory, the wget command is a free tool to download files automatically from the network, for specific use, please refer to this article: http://www.jb51.net/os/RedHat/73089.html

Note: The number in the command is the version number, you can also change the 3.3.0 to the version you need, as of the time I wrote (January 29, 2013), the latest available version is 3.3.0

3rd Step: Unzip the downloaded binary package and compile the installation

Copy CodeThe code is as follows:
#tar-JXVF python-3.3.0.tar.bz2
#cd Python-3.3.0
#./configure
#make All
#make Install
#make Clean
#make Distclean
#/usr/local/bin/python3–v

After compiling the installation, you can enter the above line command to view the version

4th step: Establish a soft connection to the bin directory of the current system default Python command, let the system use the new version of Python
#mv/usr/bin/python/usr/bin/python2.4//Current Python version is 2.4 so it's python2.4.
#ln-S/usr/local/bin/python3.3/usr/bin/python
Enter #python-v to view the current default Python version
After the default Python successfully points to 3.3.0, Yum does not work, and the Yum configuration file needs to be modified

5th Step: Modify the Yum configuration file

#vi/usr/bin/yum
Change the #!/usr/bin/python of the head of the file to #!/usr/bin/python2.4//change to the previous old version number
Save and exit, Yum will work. If there are other commands, the software does not work properly, follow the Yum configuration file modification method, modify its configuration file.
This completes the update.

Steps to update the Python version under CentOS

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.