macOS Mojave Pyenv 安装多版本 build failed 解决办法

Image result for pythonImage result for macos mojave

Build Failed

在 macOS Mojave 上,如果你想要安装多版本的 python,你会遇到 build failed 这样的错误,像这样:

 

BUILD FAILED (OS X 10.14.1 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/wm/hm_v7w195c7ftkk6rjlk9qlc0000gn/T/python-build.20181208174645.70936
Results logged to /var/folders/wm/hm_v7w195c7ftkk6rjlk9qlc0000gn/T/python-build.20181208174645.70936.log

Last 10 log lines:
File "/private/var/folders/wm/hm_v7w195c7ftkk6rjlk9qlc0000gn/T/python-build.20181208174645.70936/Python-3.6.7/Lib/ensurepip/__main__.py", line 5, in <module>
sys.exit(ensurepip._main())
File "/private/var/folders/wm/hm_v7w195c7ftkk6rjlk9qlc0000gn/T/python-build.20181208174645.70936/Python-3.6.7/Lib/ensurepip/__init__.py", line 204, in _main
default_pip=args.default_pip,
File "/private/var/folders/wm/hm_v7w195c7ftkk6rjlk9qlc0000gn/T/python-build.20181208174645.70936/Python-3.6.7/Lib/ensurepip/__init__.py", line 117, in _bootstrap
return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/private/var/folders/wm/hm_v7w195c7ftkk6rjlk9qlc0000gn/T/python-build.20181208174645.70936/Python-3.6.7/Lib/ensurepip/__init__.py", line 27, in _run_pip
import pip._internal
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1

 

Stackoverflow 和 github 上一些帖子说输入这个可以解决

xcode-select --install

但我试验过,在 Mojave 上无法解决

Solution

我在 github 上看到解决办法,特此记录。

在 Mojave 上,输入:

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

然后安装新的 Python 版本,像这样:

pyenv install 3.6.7

成功!

One Comment

发表评论

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据