2012年6月14日木曜日

ユーザーhomeにpython2.7.3(ついでにPython3.2.3も)をインストールしたときのメモ

目的

職場のRHEL5上のhomeにpython2.7をインストールしたい。管理者権限はない。

やり方

インストール先は$HOME/.localとする。.local/以下にbin, libなどが作成される。

Pythonをインストール

pythonのソースを本家からwgetして持ってきて、configure(インストール先の指定は--prefix)してmake installすれば良いかと思ったが、
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar xvzf Python-2.7.3.tgz
cd Python-2.7.3
.configure --prefix=$HOME/.local
make install
ここで、
hg identify: option -i not recognized
hg identify: option -t not recognized
hg identify: option -b not recognized
./Modules/getbuildinfo.c: In function ‘Py_GetBuildInfo’:
./Modules/getbuildinfo.c:45: error: missing terminating " character
./Modules/getbuildinfo.c:45: error: expected expression before ‘)’ token
./Modules/getbuildinfo.c:46: error: missing terminating " character
./Modules/getbuildinfo.c:46: error: missing terminating " character
./Modules/getbuildinfo.c:47: error: missing terminating " character
./Modules/getbuildinfo.c:47: error: missing terminating " character
./Modules/getbuildinfo.c:53: error: ‘buildinfo’ undeclared (first use in this function)
./Modules/getbuildinfo.c:53: error: (Each undeclared identifier is reported only once
./Modules/getbuildinfo.c:53: error: for each function it appears in.)
./Modules/getbuildinfo.c: In function ‘_Py_hgversion’:
./Modules/getbuildinfo.c:72: error: missing terminating " character
./Modules/getbuildinfo.c:72: warning: ‘return’ with no value, in function returning non-void
./Modules/getbuildinfo.c: In function ‘_Py_hgidentifier’:
./Modules/getbuildinfo.c:79: error: missing terminating " character
./Modules/getbuildinfo.c:79: error: expected expression before ‘;’ token
./Modules/getbuildinfo.c:83: error: missing terminating " character
./Modules/getbuildinfo.c:83: error: expected expression before ‘;’ token
make: *** [Modules/getbuildinfo.o] Error 1
こんな感じのエラーがでた。調べてみると、自分の環境では、Mercurialのバージョンが古いらしい。
$ hg --version
Mercurial Distributed SCM (version 0.9.3)

Copyright (C) 2005, 2006 Matt Mackall 
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Mercurialの新しいのをインストール

今は2.2とからしい。古すぎだろw。ということで、先にMercurialの2.2.2をhomeにインストールする。
cd ..
wget http://mercurial.selenic.com/release/mercurial-2.2.2.tar.gz
tar xzvf mercurial-2.2.2.tar.gz
cd mercurial-2.2.2
PREFIX=$HOME/.local make install
インストール先はPREFIXに指定するらしい。なんか最後の方にpython-docutilsかなんかをinstallしろ、とerrorがでるが無視。一応インストール完了。インストール先のbinディレクトリをPATHの先頭に加えれば、2.2.2のhgが呼ばれる。
$ export PATH=$HOME/.local/bin:$PATH
$ $HOME/.local/bin/hg --version
Mercurial Distributed SCM (version 2.2.2)
(see http://mercurial.selenic.com for more information)

Copyright (C) 2005-2012 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Pythonのインストール続き

Pythonのディレクトリに戻り、再度make installする。
cd ../Python-2.7.3
make install
インストールできた。 $HOME/.local/bin/pythonにaliasもしくはPATHを通せば、使えます。
alias python=$HOME/.local/bin/python
# OR
export PATH=$HOME/.local/bin:$PATH
$ python --version
Python 2.7.3

ついでにPython3.2.3もインストール

wget http://www.python.org/ftp/python/3.2.3/Python-3.2.3.tgz
tar xvzf Python-3.2.3.tgz
cd Python-3.2.3
./configure --prefix=$HOME/.local
make install
何の問題もなくインストール完了。$HOME/.localにはパスを通してあったので、
$ python3
Python 3.2.3 (default, Jun 15 2012, 11:09:08) 
[GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
とpython3で呼べる。
ソースファイルへのリンクが切れていたらコチラ。Python mercurial Python-3.2.3

0 件のコメント:

コメントを投稿