The error
If you are installing python with pyenv and get the error:
zipimport.ZipImportError: can't decompress data; zlib not available
Zlib and xcode already installed
Something is broken on your system, try to reexecute:
xcode-select --install
Check for empty space
First Check that uou have enough freespace in your harddrive, especially on the /tmp. Use the command df -h to check freespace. Usually this error is shown when no space is available without warning.
Naive solution: install zlib
If you have space upgrade zlib version or install it.
brew update
brew upgrade
brew install zlib
export CFLAGS="-I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include"
export LDFLAGS="-L$(brew --prefix openssl)/lib"
pyenv install 3.6.0
Error while trying to install python with pyenv
$ pyenv install 3.6.0
Downloading Python-3.6.0.tar.xz...
-> https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz
Installing Python-3.6.0...
BUILD FAILED (OS X 10.12.4 using python-build 20160602)
Inspect or clean up the working tree at /var/folders/1f/pdmszzls4xs6px9gmf627ng40000gn/T/python-build.20170409145711.16182
Results logged to /var/folders/1f/pdmszzls4xs6px9gmf627ng40000gn/T/python-build.20170409145711.16182.log
Last 10 log lines:
File "/private/var/folders/1f/pdmszzls4xs6px9gmf627ng40000gn/T/python-build.20170409145711.16182/Python-3.6.0/Lib/ensurepip/__main__.py", line 4, in <module>
ensurepip._main()
File "/private/var/folders/1f/pdmszzls4xs6px9gmf627ng40000gn/T/python-build.20170409145711.16182/Python-3.6.0/Lib/ensurepip/__init__.py", line 189, in _main
default_pip=args.default_pip,
File "/private/var/folders/1f/pdmszzls4xs6px9gmf627ng40000gn/T/python-build.20170409145711.16182/Python-3.6.0/Lib/ensurepip/__init__.py", line 102, in bootstrap
_run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/private/var/folders/1f/pdmszzls4xs6px9gmf627ng40000gn/T/python-build.20170409145711.16182/Python-3.6.0/Lib/ensurepip/__init__.py", line 27, in _run_pip
import pip
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1