If you are getting the following error:
pyenv install 3.8.6
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.6.tar.xz...
-> https://www.python.org/ftp/python/3.8.6/Python-3.8.6.tar.xz
Installing Python-3.8.6...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
BUILD FAILED (OS X 11.1 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/6x/cp1l4tr97y7g3jxm74n4c6v80000gn/T/python-build.20210106100539.35673
Results logged to /var/folders/6x/cp1l4tr97y7g3jxm74n4c6v80000gn/T/python-build.20210106100539.35673.log
Last 10 log lines:
mod_name, mod_spec, code = _get_module_details(mod_name)
File "/private/var/folders/6x/cp1l4tr97y7g3jxm74n4c6v80000gn/T/python-build.20210106100539.35673/Python-3.8.6/Lib/runpy.py", line 144, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/private/var/folders/6x/cp1l4tr97y7g3jxm74n4c6v80000gn/T/python-build.20210106100539.35673/Python-3.8.6/Lib/runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "<frozen zipimport>", line 241, in load_module
File "<frozen zipimport>", line 709, in _get_module_code
File "<frozen zipimport>", line 570, in _get_data
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1
It breaks because Python installation cannot find zlib.
The solution is easy - provide CFLAGS from the xcode sdk:
$ CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install 3.8.6
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.6.tar.xz...
-> https://www.python.org/ftp/python/3.8.6/Python-3.8.6.tar.xz
Installing Python-3.8.6...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.8.6 to /Users/kuba/.pyenv/versions/3.8.6
Top comments (7)
This unlocked a full day of messing with my python environments thank you.
likewise! thank you Jakub
Jakub, could you point me in the right direction, please. I am facing the same issue. In fact, the exact same issue when trying to install Python but my version is 2.7.7.
I infer that you are entering this code in the zshell in the M1 MacBook Pro, right?
If not, where is it that I should enter this code? I am really new to this. If I need to learn something else like xcode please point me in the direction that I need to be heading. Thanks in advance!
Hi Joseph,
unfortunately I don't have M1 MacBook or python 2.7 - so I cannot say if this is the same problem.
I tried with this solution but didn't work, but these one worked for python 3.5, 3.6 and 3.9
github.com/pyenv/pyenv/issues/1737...
This issue was about to drive me friggin' crazy ... 🤦 Many thanks for posting this Jakub 😄
I'm still stuck with the same problem(( M1 mac