To update Python in centos

Source: Internet
Author: User

After CentOS5.9 (Final) is installed, run # Python and # python-V. You can see that the version number is 2.4.3, which is very old. What you wrote earlier is running on python3.X. 3. X and 2. X has many differences. If you are interested, refer to the following article:

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

Do not delete old python versions when updating python! New and old versions can coexist. Many basic commands and software packages must depend on the pre-installed old version of python, such as yum.

Update python:

Step 2: Update gcc. If the gcc version is too old, the new python package cannot be compiled.

Copy codeThe Code is as follows: # yum-y install gcc

The system will automatically download, install, or update the SDK.

Step 2: Download the Python-2nd Software Package

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

Note: The software package downloaded according to the above commands will be stored in your current working directory. The wget command is a free tool for automatically downloading files from the network. For detailed usage, 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 3.3.0 to the version you need. By the time of writing, the latest available version is 3.3.0.

Step 2: Decompress the downloaded Binary Package and compile and install it.
Copy codeCode: # 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 compilation and installation, enter the preceding command to view the version.

Step 2: Establish a soft connection to point to the bin directory of the default python command in the current systemAllows the system to use the new python version.
# Mv/usr/bin/python/usr/bin/python2.4 // The current python version is 2.4, so it is 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 point to 3.3.0, yum cannot be used normally. You need to modify the yum configuration file.

Step 2: Modify the yum configuration file

# Vi/usr/bin/yum
#! /Usr/bin/python #! /Usr/bin/python2.4 // change to the old version number
Save and exit. yum can be used normally. If other commands and software cannot be used normally, modify the configuration file just like the yum configuration file.
So far, the update is complete.

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.