Python3.7入れる時に `No module named '_ctypes'` エラー
Python3.6までは問題なくビルドできたのに3.7で _ctypes
のエラーがでてビルドできないといった嘆きをよく見ます。
$ pipenv --python 3.7.2 Warning: Python 3.7.2 was not found on your system… Would you like us to install CPython 3.7.2 with pyenv? [Y/n]: Y Installing CPython 3.7.2 with pyenv (this may take a few minutes)… ✘ Failed... Something went wrong… Downloading Python-3.7.2.tar.xz... -> https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz Installing Python-3.7.2... BUILD FAILED (CentOS Linux 7 using python-build 20180424) Inspect or clean up the working tree at /tmp/python-build.20190405065753.24551 Results logged to /tmp/python-build.20190405065753.24551.log Last 10 log lines: File "/tmp/tmpregj5qs2/pip-18.1-py2.py3-none-any.whl/pip/_internal/commands/__init__.py", line 6, in <module> File "/tmp/tmpregj5qs2/pip-18.1-py2.py3-none-any.whl/pip/_internal/commands/completion.py", line 6, in <module> File "/tmp/tmpregj5qs2/pip-18.1-py2.py3-none-any.whl/pip/_internal/cli/base_command.py", line 18, in <module> File "/tmp/tmpregj5qs2/pip-18.1-py2.py3-none-any.whl/pip/_internal/download.py", line 38, in <module> File "/tmp/tmpregj5qs2/pip-18.1-py2.py3-none-any.whl/pip/_internal/utils/glibc.py", line 3, in <module> File "/tmp/python-build.20190405065753.24551/Python-3.7.2/Lib/ctypes/__init__.py", line 7, in <module> from _ctypes import Union, Structure, Array ModuleNotFoundError: No module named '_ctypes' make[1]: *** [install] Error 1 make[1]: Leaving directory `/tmp/python-build.20190405065753.24551/Python-3.7.2' Warning: The Python you just installed is not available on your PATH, apparently. make: *** [setup] Error 1
libffi
をインストールすると良いようです。
CentOS系列だと以下のコマンドでインストールできます。
$ sudo yum install libffi-devel
理由は公式ドキュメントに載ってました。
A full copy of libffi is no longer bundled for use when building the ctypes module on non-OSX UNIX platforms. An installed copy of libffi is now required when building ctypes on such platforms. (Contributed by Zachary Ware in bpo-27979.)
今回から必要だよって感じの事を言ってます。
また、下記からOpenSSLのバージョンが古すぎてもダメそうですね。
The ssl module requires OpenSSL 1.0.2 or 1.1 compatible libssl. OpenSSL 1.0.1 has reached end of lifetime on 2016-12-31 and is no longer supported. LibreSSL is temporarily not supported as well. LibreSSL releases up to version 2.6.4 are missing required OpenSSL 1.0.2 APIs.
Python3.7は現行最新のPythonです。(執筆時2019/04/06)
アップデートして良いPythonライフを送ってください。
続報
やっぱりOpenSSLのエラーに遭遇しました。