Pythonをビルド
[caty-depl] というタグで、Catyの配備に関するメモを書くことにした。時間順(今日は、上から下に向かう順でエントリーを書く)が前後してしまうことになるが、とりあえずPythonのビルドから。
さくらサーバー(さくらの専用サーバSempron)を使っているが、/usr/bin/python は、2.3.4だった。
[hiyama@microapplications ~]$ which python
/usr/bin/python
[hiyama@microapplications ~]$ python -V
Python 2.3.4
[hiyama@microapplications ~]$ ls -lFi /usr/bin/py*
1103933 -rwxr-xr-x 2 root root 5396 Jul 26 2008 /usr/bin/python*
1103853 lrwxrwxrwx 1 root root 6 Oct 7 2008 /usr/bin/python2 -> python*
1103933 -rwxr-xr-x 2 root root 5396 Jul 26 2008 /usr/bin/python2.3*
[hiyama@microapplications ~]$ python
Python 2.3.4 (#1, Jul 25 2008, 14:24:21)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path (以下、折り返した)
['',
'/usr/lib/python2.3/site-packages/setuptools-0.6c7-py2.3.egg',
'/usr/lib/python2.3/site-packages/TracXMLRPC-0.1-py2.3.egg',
'/usr/lib/python2.3/site-packages/Genshi-0.4.4-py2.3.egg',
'/usr/lib/python23.zip',
'/usr/lib/python2.3',
'/usr/lib/python2.3/plat-linux2',
'/usr/lib/python2.3/lib-tk',
'/usr/lib/python2.3/lib-dynload',
'/usr/lib/python2.3/site-packages',
'/usr/lib/python2.3/site-packages/PIL',
'/usr/lib/python2.3/site-packages/gtk-2.0']
suして、なんやかんや。
# wget http://www.python.org/ftp/python/2.6.4/Python-2.6.4.tgz
# tar zxvf Python-2.6.4.tgz
# cd Python-2.6.4
# ./configure --prefix=/usr/local/python
# make
# make install
これで、
[hiyama@microapplications ~]$ /usr/local/python/bin/python -V
Python 2.6.4
prefixを、/usr/local/python じゃなくて /usr にすると、以下にインストールされる。
- /usr/bin/python
- /usr/lib/python2.6/
- /usr/include/python2.6/
標準的な利用では、/usr直下におくべきだろうが、とりあえずはこのままにして、パスを追加しておこう。
# .bash_profile# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi# User specific environment and startup programs
PATH=/usr/local/python/bin:$PATH:$HOME/bin
export PATH
unset USERNAME
[hiyama@microapplications ~]$ . ~/.bash_profile
[hiyama@microapplications ~]$ which python
/usr/local/python/bin/python
[hiyama@microapplications ~]$ python -V
Python 2.6.4
[hiyama@microapplications ~]$ python
Python 2.6.4 (r264:75706, Jan 21 2010, 23:22:41)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['',
'/usr/local/python/lib/python26.zip',
'/usr/local/python/lib/python2.6',
'/usr/local/python/lib/python2.6/plat-linux2',
'/usr/local/python/lib/python2.6/lib-tk',
'/usr/local/python/lib/python2.6/lib-old',
'/usr/local/python/lib/python2.6/lib-dynload',
'/usr/local/python/lib/python2.6/site-packages']