9 steps to upgrade CentOS5 system Python version to 2.7

888u

Last update at :2024-06-15,Edit by888u

For web language snails who are familiar with ASP and PHP, they can easily understand and modify it. When it comes to other languages ​​​​such as Python, they are basically illiterate, but some need to support Python2 when testing and practicing certain tutorials. .7 version, the default CentOS is version 2.4.3. So I had to upgrade before I could use the backup script I was going to test (Qiniu storage backup requires version 2.7).

Similarly, many online tutorials either have problems with the data source or the scripts are not clear, at least for novices, it is difficult to proceed. The following method and process can upgrade the Python version. I also tested it three times (my system is centos 5).

The first step is to check the current Python version

python -V

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

The second step, yun installs the GCC compiler

yum -y install gcc

The third step, download/unzip the Python-2.7.2 installation package

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

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

tar -jxvf Python-2.7.2.tar.bz2

Step 4, enter the Python folder directory

cdPython-2.7.2

Step 5, Installation

./configuremake allmake installmake cleanmake distclean

Step 6: Check whether version 2.7 is effective

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

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

Step 7, point to python2.7 by default

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

It should be noted that you need to enter a \\"y\\" after the first line.

Step 8. Test the current system version

Step 9, solve the problem

Currently we need to solve the problem that yun cannot be used normally after 2.7.

vi /usr/bin/yum

will

#!/usr/bin/python

Modify to

#!/usr/bin/python2.4

That solves the problem. The steps are a bit cumbersome, and Snail will definitely not copy them. Every article must be tested before being shared, because only in order to ensure that everyone can use it in good condition.

Recommended site search: domain name registration number query, registration-free, domain name space, how to check ip, virtual host server, ip reverse domain name query, Korean independent server, virtual host space, dynamic dial-up vps host, ip address search,

p>

9 steps to upgrade CentOS5 system Python version to 2.7

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码