pyenv install VERSION で Missing the OpenSSL lib?と言われた

macOSをHigh Sierraにアップデートしたあと、pyenv install 3.5.4すると、エラーが発生した。

エラー表示は次のようなものでした。

ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems

BUILD FAILED (OS X 10.13.1 using python-build 20160602)

Inspect or clean up the working tree at /var/folders/g5/4kh2tkbn209byhb62z0931d40000gp/T/python-build.20171216223357.25585
Results logged to /var/folders/g5/4kh2tkbn209byhb62z0931d40000gp/T/python-build.20171216223357.25585.log

Last 10 log lines:
(cd /Users/<USERNAME>/.pyenv/versions/3.5.4/share/man/man1; ln -s python3.5.1 python3.1)
if test "xupgrade" != "xno"  ; then \
        case upgrade in \
            upgrade) ensurepip="--upgrade" ;; \
            install|*) ensurepip="" ;; \
        esac; \
        ./python.exe -E -m ensurepip \
            $ensurepip --root=/ ; \
    fi
Ignoring ensurepip failure: pip 9.0.1 requires SSL/TLS

解決策

助言を求めろと言われたページ Common build problems · pyenv/pyenv Wiki · GitHub にアクセスしたら、ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?という見出しがあるので、そこの手順を踏むと解決できました。

CFLAGS="-I$(brew --prefix openssl)/include" \
LDFLAGS="-L$(brew --prefix openssl)/lib" \
pyenv install 3.5.4

上記の実行でOKでした。詳細ログの出力フラグ-vは省略しました。

pyenv導入時にもこんなことがあったような気がしないでもないです。一応メモしておこうと思いました。