操作系统:MacOS 10.14 Beta
目标:通过PYENV安装Python 3.7.0
尝试通过pyenv安装python 3.7.0时出现此错误,该如何解决?
Last 10 log lines:
File "/private/tmp/python-build.20180704152803.38921/Python-3.7.0/Lib/ensurepip/__main__.py", line 5, in <module>
sys.exit(ensurepip._main())
File "/private/tmp/python-build.20180704152803.38921/Python-3.7.0/Lib/ensurepip/__init__.py", line 204, in _main
default_pip=args.default_pip,
File "/private/tmp/python-build.20180704152803.38921/Python-3.7.0/Lib/ensurepip/__init__.py", line 117, in _bootstrap
return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/private/tmp/python-build.20180704152803.38921/Python-3.7.0/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
尝试修复的步骤:
1)重新安装XCODE
2)重新安装XCODE命令行工具
3)阅读有关堆栈溢出的类似错误
替代问题:
1)应该预装了zlib,我可能会遇到哪种问题?
2)是将python手动安装到pyenv中的另一种方法,也可以被pynev识别吗?
答案 0 :(得分:1)
特别是对于Python 3.7.0,我成功完成了以下工作:
当您运行info zlib时,Brew提供了一些很好的说明
iexpress.exe
因此,按照这些说明,我只需剪切/粘贴FTW:)
$ brew info zlib
...
For compilers to find zlib you may need to set:
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"
...
答案 1 :(得分:0)
我有同样的问题。首先,我尝试使用以下方式手动安装python
./configure --prefix /usr/local/var/pyenv/versions/3.5.5/
make
make install
构建完成,但是我也遇到关于openssl和zlib的错误。然后,我再次尝试更改构建环境:
export CPPFLAGS="-I/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I$(brew --prefix openssl)/include"
export LDFLAGS="-L/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib -L$(brew --prefix openssl)/lib"
成功了。
最后,我在同一个shell中运行(带有两个导出的变量):
pyenv install 3.5.5
也成功了:-) HTH