由於要在linux中使用python 2.5版本,結果Ubuntu 10.04默認版本為2.6,因此要安裝2.5版本,並將其默認編譯器改為2.5版本的。
下面是主要步驟:
1. 下載源代碼:
wget http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tar.bz2
2. 解壓壓縮包:
$ tar –jxvf Python-2.5.2.tar.bz2
3. 安裝python 2.5
$ cd Python-2.5.2
$ ./configure
$ make
$ make install
安裝完成後,輸入python,驗證其安裝成功與否。
4. 修改默認版本:
$ cd /usr/bin
$ ll |grep python //查看該目錄下python
$ rm -rf python
$ ln -s 安裝目錄前綴/Python-2.5.2/python ./python //可能需要root權限,可用sudo ...
$ python -V
至此,版本就修改完畢,變成了2.5.2了。