CentOS5.9にPython2.7を入れる
ReviewBoardを入れたい。
そのためにはPythonのバージョンを2.7にしたい。
# yum install zlib zlib-devel tk-devel tcl-devel sqlite-devel ncurses-devel gdbm-devel readline-devel bzip2-devel db4-devel openssl-devel mod-ssl
# wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2 # tar xvf Python-2.7.5.tar.bz2 # cd Python-2.7.5 # ./configure --with-threads --enable-shared --prefix=/usr/local --enable-ssl
opensslの位置を調べておく
# find / -name openssl /usr/bin/openssl /usr/lib/openssl /usr/include/openssl
sslを読み込むようにするため./Module/Setupを編集
これを
#SSL=/usr/local/ssl #_ssl _ssl.c \ # -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ # -L$(SSL)/lib -lssl -lcrypto
こう
SSL=/usr _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto
# make & make altinstall # cd /lib/ # ln /usr/local/lib/libpython2.7.so.1.0 libpython2.7.so.1.0 # python2.7 -V Python 2.7.3
しかし古いPythonが残る。これは事件。
# python -V Python 2.4
pythonでも2.7が動くように。
# ln -s /usr/local/bin/python2.7 /usr/local/bin/python
ログインしなおすと
# python -V Python 2.7.3
もし下記のようなエラーが出たら
Could not find platform independent libraries <prefix> Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] ImportError: No module named site
~/.bashrcにaliasを書けば解決します。