Link: http://blog.pmal.net/2011/03/02/linux_python_upgrade/
I have been learning Python recently, but the built-in Python 2.4.3 is too old.
The website has been upgraded to 3.2.
I chose to upgrade to 2.7 on the official website. Because my teaching materials support more than 2.5, 3.2 is still too new, and it is almost the same as upgrading to 2.7.
Download source code
1 |
wget http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tgz |
All my software is downloaded under/data0/software,
In this directory, decompress
1 |
tar -zxvf Python-2.7.1.tgz |
Start compiling
1 |
mkdir /usr/local/python27 |
I created a directory
During compilation
1 |
./configure --prefix=/usr/local/python27 |
The old version has not been overwritten.
Then change the original
The following python links are all deleted or changed to another name.
1 |
mv /usr/bin/python /usr/bin/python_old |
Enter
1 |
ln -s /usr/local/python27/bin/python /usr/bin/ |
Enter
The following code is displayed:
1 |
Python 2.7.1 (r271:86832, Mar 2 2011, 12:06:34)
|
2 |
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2 |
3 |
Type "help",
"copyright", "credits"
or "license" for more information. |