Focus on cloud service provider activities
Notes on website operation and maintenance

Step 9 Upgrade the Python version of CentOS5 system to 2.7

The simple thing that Lao Zuo is familiar with ASP and PHP is that he can understand and modify them. Other languages such as Python are basically illiterate, but some of them need to support Python 2.7 when testing and practicing some tutorials. The default CentOS is 2.4.3. So it is necessary to upgrade before I can use the backup script I will test (version 2.7 is required for 7N storage backup).

Similarly, many online tutorials were found either because the data source was faulty or the script was unclear, at least for novices. The following method and process can upgrade the Python version. I also tested it three times (my system is centos 5).

Step 1: Check the current Python version

 python -V

 Check the current python version

We see that the default version is 2.4.3, which does not meet the requirements of the program and needs to be upgraded.

Step 2: Install GCC compiler by yun

 yum -y install gcc

Step 3. Download/unzip the Python - 2.7.2 installation package

 wget -O Python-2.7.2.tar.bz2 https://www.dropbox.com/s/7ia7obzbsagl3zb/Python-2.7.2.tar.bz2

It is recommended to download manually instead of using wget, because when using wget, the file name will have a hash value. After manual download, it will be uploaded to the root directory

 tar -jxvf Python-2.7.2.tar.bz2

Step 4: Enter the Python folder directory

 cd Python-2.7.2

Step 5. Installation

 ./configure make all make install make clean make distclean

Step 6: Check whether the 2.7 version is effective

 /usr/local/bin/python2.7 -V

 python-2

This is not the information of the current version, but to see whether the 2.7 directory has taken effect. The current version is still 2.4.3. We need to use soft connection to convert.

Step 7: Point to python 2.7 by default

 mv /usr/bin/python /usr/bin/python2.4 ln -s /usr/local/bin/python2.7 /usr/bin/python

 python-3

Note that you need to enter a "y" after the first line.

Step 8. Test the current system version

 Python version check

Step 9. Solve the problem

At present, we need to solve the problem that after pointing to 2.7, yun cannot be used normally.

 vi /usr/bin/yum

take

 #!/ usr/bin/python

Modify to

 #!/ usr/bin/python2.4

 python-6

So we solved the problem. The steps are a little cumbersome, and Lao Zuo will definitely not copy them. Any article must be tested before sharing, because it can ensure that everyone can use it well.

Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » Step 9 Upgrade the Python version of CentOS5 system to 2.7


Scan the code to follow the official account

Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge