更新Python到2.7

眼看着python3 都出来了,vps上用的还是2.4的版本额,确实汗了一把。决定升级下python。

python2.7是2.X的最后一个版本,同时她也加入了一部分3.X的新特性。so 让我们升级吧!
查看系统当前python版本
2:

 [root@wangyuelou ~]# python
1:
3:

 Python 2.4.3 (#1, May  5 2011, 16:39:10)
4:

 [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
5:

 Type "help", "copyright", "credits" or "license" for more information.
6:

 >;>>
7:

 [root@wangyuelou ~]#
下载新版本的python

解压缩 以及编译

1:

 [root@wangyuelou ~]# tar xvf Python-2.7.2.tar.bz2
2:

 [root@wangyuelou Python-2.7.2]# ./configure --prefix=/usr/local/python27
3:

 [root@wangyuelou Python-2.7.2]# make
4:

 [root@wangyuelou Python-2.7.2]# make install
5:

 [root@wangyuelou Python-2.7.2]# ls /usr/local/python27/ -al
6:

 total 28
7:

 drwxr-xr-x  6 root root 4096 Jul 14 00:21 .
8:

 drwxr-xr-x 20 root root 4096 Jul 14 00:17 ..
9:

 drwxr-xr-x  2 root root 4096 Jul 14 00:21 bin
10:

 drwxr-xr-x  3 root root 4096 Jul 14 00:21 include
11:

 drwxr-xr-x  4 root root 4096 Jul 14 00:21 lib
12:

 drwxr-xr-x  3 root root 4096 Jul 14 00:21 share
覆盖原来的python链接
1:

 [root@wangyuelou Python-2.7.2]# mv /usr/bin/python /usr/bin/python_old
2:

 [root@wangyuelou Python-2.7.2]# ln -s /usr/local/python27/bin/python /usr/bin/
3:

 [root@wangyuelou Python-2.7.2]# python
4:

 Python 2.7.2 (default, Jul 14 2011, 00:20:14)
5:

 [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
6:

 Type "help", "copyright", "credits" or "license" for more information.
7:

 >>>

相关推荐