Ubuntu10.04に複数のPythonをインストールする方法

Ubuntu10.04はデフォルトでPython 2.6がインストールされています。
この環境に2.7、3.2とGoogle App Engine(GAE)用に2.5をインストールした時のメモを転記しておきます。



●前準備

./configure --prefix=/usr/bin/python2.7 --with-threads --enable-shared
sudo apt-get install zlib1g-dev bzip2 libbz2-dev libreadline5-dev libjpeg62 libjpeg62-dev libfreetype6 libfreetype6-dev libsqlite3-0 libsqlite3-dev libgdbm3 libgdbm-dev libssl0.9.8 libssl-dev tk8.4-dev tk8.5-dev

Python 2.7

wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz
tar zxvf Python-2.7.2.tgz
cd Python-2.7.2/
./configure --prefix=/opt/python2.7 --with-threads --enable-shared
make
sudo make install
sudo strip /opt/python2.7/bin/python*
sudo ln -s /opt/python2.7/bin/python /usr/bin/python2.7
sudo vi /etc/ld.so.conf.d/opt-python2.7.conf

# 下記を追記
/opt/python2.7/lib

sudo /sbin/ldconfig


●Python3.2

wget http://www.python.org/ftp/python/3.2.2/Python-3.2.2.tgz
tar xzvf Python-3.2.2.tgz
cd Python-3.2.2/
./configure --prefix=/opt/python3.2 --with-threads --enable-share
make
sudo make install
sudo strip /opt/python3.2/bin/python*
sudo ln -s /opt/python3.2/bin/python3.2 /usr/bin/python3.2
sudo vi /etc/ld.so.conf.d/opt-python3.2.conf

# 下記を追記
/opt/python3.2/lib

sudo /sbin/ldconfig