macOS 10.13.4 High Sierra で
$pyenv install 3.6.3
としたところ
BUILD FAILED (OS X 10.13.4 using python-build 1.0.7-189-gaf8cca9)
というエラーが出た。
これを解決するメモ。
$xcode-select --install
を実行し、Xcode の command line developer tools をインストール。
すると...
まだ Python3 のインストールは成功しなかったが、エラーメッセージが変わった。
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
OpenSSL のライブラリーが見つかっていない模様。
エラーメッセージの中に、
Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems
とサジェストが書かれていたのでそのサイトを見てみると答えが書かれていた。
$CFLAGS="-I$(brew --prefix openssl)/include" \
LDFLAGS="-L$(brew --prefix openssl)/lib" \
pyenv install 3.6.3
これで解決。
この解に至るまでに
$brew install opnssl@1.1
もしたのだが、これが必要かどうかはわからない。
今回は必要なかったが Missing the zlib? というエラーメッセージが出たときは、brew install readline xz で解決するらしい。