メモ
環境: Mac OSX 10.15.1(19B88)
pyenvで新しいpythonバージョンをインストールしようとすると、以下のエラーが出ることがある。
terminal
$ pyenv install python3.6.2
python-build: definition not found: python3.6.2
See all available versions with `pyenv install --list'.
If the version you need is missing, try upgrading pyenv:
$ pyenv install 3.6.2
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.6.2.tar.xz...
-> https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
Installing Python-3.6.2...
python-build: use readline from homebrew
BUILD FAILED (OS X 10.15.1 using python-build 1.2.8)
Inspect or clean up the working tree at /var/folders/3k/g2s6z15s20q8bzy_5btxg29r0000gn/T/python-build.20191218194948.78102
Results logged to /var/folders/3k/g2s6z15s20q8bzy_5btxg29r0000gn/T/python-build.20191218194948.78102.log
Last 10 log lines:
File "/private/var/folders/3k/g2s6z15s20q8bzy_5btxg29r0000gn/T/python-build.20191218194948.78102/Python-3.6.2/Lib/ensurepip/__main__.py", line 4, in <module>
ensurepip._main()
File "/private/var/folders/3k/g2s6z15s20q8bzy_5btxg29r0000gn/T/python-build.20191218194948.78102/Python-3.6.2/Lib/ensurepip/__init__.py", line 189, in _main
default_pip=args.default_pip,
File "/private/var/folders/3k/g2s6z15s20q8bzy_5btxg29r0000gn/T/python-build.20191218194948.78102/Python-3.6.2/Lib/ensurepip/__init__.py", line 102, in bootstrap
_run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/private/var/folders/3k/g2s6z15s20q8bzy_5btxg29r0000gn/T/python-build.20191218194948.78102/Python-3.6.2/Lib/ensurepip/__init__.py", line 27, in _run_pip
import pip
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1
と表示が出る場合は、以下で回避できる。
CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install 3.6.2