无法在 Mac Mojave 上安装 pythion 3

无法在 Mac Mojave 上安装 pythion 3

我最近将我的 MAC 升级到了 Mojave(版本:10.14.3 (18D109)),然后尝试通过以下 SO 链接立即安装 Python 3.7这里

但是我无法继续,因为 brew 始终无法安装 Python。以下是终端输出。

Last login: Thu Mar 14 19:50:58 on ttys003
MyMac:~ macuser$ pyenv install 3.7.2
python-build: use openssl from homebrew
python-build: use readline from homebrew
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...
python-build: use readline from homebrew

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

Inspect or clean up the working tree at /var/folders/5l/gwy_gpdj6wvf_24z0mj5kyxwpdzls9/T/python-build.20190314202748.51576
Results logged to /var/folders/5l/gwy_gpdj6wvf_24z0mj5kyxwpdzls9/T/python-build.20190314202748.51576.log

Last 10 log lines:
  File "/private/var/folders/5l/gwy_gpdj6wvf_24z0mj5kyxwpdzls9/T/python-build.20190314202748.51576/Python-3.7.2/Lib/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/private/var/folders/5l/gwy_gpdj6wvf_24z0mj5kyxwpdzls9/T/python-build.20190314202748.51576/Python-3.7.2/Lib/ensurepip/__init__.py", line 204, in _main
    default_pip=args.default_pip,
  File "/private/var/folders/5l/gwy_gpdj6wvf_24z0mj5kyxwpdzls9/T/python-build.20190314202748.51576/Python-3.7.2/Lib/ensurepip/__init__.py", line 117, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/private/var/folders/5l/gwy_gpdj6wvf_24z0mj5kyxwpdzls9/T/python-build.20190314202748.51576/Python-3.7.2/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
MyMac:~ macuser$ open /var/folders/5l/
MyMac:~ macuser$ 

我努力了

  1. 按照以下步骤修复 xcode 问题这里

  2. 重新启动我的机器。

  3. 使用 brew 重新安装 zlib

答案1

经过更多搜索后,我找到了以下有效的答案。至少解决了当前的问题这里

为了能够帮助其他人,以下是对我有用的方法。

CFLAGS="-I$(brew --prefix readline)/include -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include" \
LDFLAGS="-L$(brew --prefix readline)/lib -L$(brew --prefix openssl)/lib" \
PYTHON_CONFIGURE_OPTS=--enable-unicode=ucs2 \
pyenv install -v 3.7.2

相关内容