あらすじ
Scientific Linux 6.1の上にてPython3.7のスクリプトを動かしたく
インストールを行った際のメモです
下準備
curlでダウンロードする際、SSL関連が古く失敗するので予めNSS含めてupdateしておく
なお、pythonのSSLライブラリにはLibreSSLを利用するので、develは不要
sudo yum update openssl curl nss libffi-devel
LibreSSL local install
2018/12/28時点でstableな2.8.3を採用
mkdir -p ~/src; cd ~/src
curl https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.8.3.tar.gz | tar zxvf -
cd libressl-2.8.3
mkdir build; cd build
../configure --prefix=$HOME/local
make -j
make install
Python3.7 local install
2018/12/28時点でstableな3.7.2を採用
mkdir -p ~/src; cd ~/src
curl https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz | tar zxvf -
cd Python-3.7.2
mkdir build; cd build
../configure --enable-optimizations --prefix=$HOME/local --with-openssl=$HOME/local
vi Modules/Setup
にて下記の場所をコメントアウト&SSLを$(HOME)/localに変更
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=$(HOME)/local
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
引き続きmakeに入る
LD_LIBRARY_PATH=$HOME/local/lib
export LD_LIBRARY_PATH
make -j
make install
これで$(HOME)/local配下にpython3.7が入るため、あとはPATHを通せばOK
エラー例
Python3実行時に下記のようなエラーが出る
(ライブラリへのパスが通ってない場合)
/home/m10i/local/bin/python3: error while loading shared libraries: libssl.so.46: cannot open shared object file: No such file or directory
その場合はLD_LIBRARY_PATHを再設定する
$ export LD_LIBRARY_PATH=$HOME/local/lib
そして次回起動時に有効になるよう、.bash_profileにも追記しておくとよい