yumパッケージ管理でpyenvを使用したpythonインストール時のビルドエラートラブルシューティング

2021年11月28日

事象

pyenvを使用してpythonをインストールしようとした時に以下のようにビルドエラーとなっている場合を想定しております。

pyenv install 3.9.0

Downloading Python-3.9.0.tar.xz...
-> https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
Installing Python-3.9.0...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

対処

以下、開発者ツールおよびpythonビルドに追加で必要なライブラリをインストールします。

yum groupinstall "Development Tools" -y

yum install zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel -y

対処後

以下のようにエラーや警告なくインストール完了すれば問題ございません。

pyenv install 3.9.0

pyenv: /root/.pyenv/versions/3.9.0 already exists
continue with installation? (y/N) y
Downloading Python-3.9.0.tar.xz...
-> https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
Installing Python-3.9.0...
Installed Python-3.9.0 to /root/.pyenv/versions/3.9.0