CentOSにpython2.7を入れる

さくらで借りたCentOSpythonはバージョンが2.4.3だった。
古いのでアップグレードしよう。
pythonは2系と3系があるけど2系が必要だったので、
一番新しい2.7.2を入れてみる。
まずはダウンロード、解凍する。

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オプション。

./configure --with-threads --enable-shared
make
make install

インストールが終わったので、

python -v

としたらエラー。

python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

ライブラリが読み込めないとのこと。
confファイルにライブラリのパスを書いておく。

emacs /etc/ld.so.conf.d/python2.7.conf

を開いて、

/usr/local/lib

と入力。
保存したら、

/sbin/ldconfig
/usr/local/bin/python

としたらpythonが起動する。

Python 2.7.2 (default, Sep 24 2011, 02:43:49) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

ldconfigとはライブラリのパスを認識させるコマンドらしい。
Linuxコマンド ldconfig 〜共有ライブラリを認識させる〜

参考:CentOS 5.5 に Python 2.6.6 をインストール