hieros
hieros

Reputation: 81

zlib not available during python 3.7.0 install through pyenv, how can I fix this?

OS: MacOS 10.14 Beta

Goal: Install Python 3.7.0 Through PYENV

When trying to install python 3.7.0 through pyenv I get this error, how can I fix this?

    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

Steps Taken To Attempt To Fix:

1) Reinstall XCODE

2) Reinstall XCODE Command Line Tools

3) Read Similar Errors on Stack Overflow

Alternate Questions:

1) zlib should come preinstalled, what kind of issue might I be experiencing?

2) What is an alternate way to manually install python into a pyenv that would also be recognized by pynev?

Upvotes: 8

Views: 5697

Answers (2)

Brian Wylie
Brian Wylie

Reputation: 2630

Specifically for Python 3.7.0 I did the following with success:

Brew gives some nice instructions when you run info zlib

$ 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"
...

So given these instructions, I simply cut/paste FTW :)

$ export LDFLAGS="-L/usr/local/opt/zlib/lib"
$ export CPPFLAGS="-I/usr/local/opt/zlib/include"
$ pyenv install 3.7.0   # Succeeded

Upvotes: 2

count_zero
count_zero

Reputation: 1

I had the same problem. First i tried to install python manually with

./configure --prefix /usr/local/var/pyenv/versions/3.5.5/
make
make install

Build completed, but i got errors about openssl and zlib , too. Then i tried again with changed build environment:

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"

Which succeeded.

Finally i ran in the same shell (with both exported variables):

pyenv install 3.5.5

Which succeeded, too :-) HTH

Upvotes: 0

Related Questions