Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zipimport.ZipImportError: can't decompress data; zlib not available on macOS #23

Open
Rokt33r opened this issue May 23, 2019 · 25 comments
Labels
bug Something isn't working

Comments

@Rokt33r
Copy link

Rokt33r commented May 23, 2019

Inspect or clean up the working tree at /var/folders/n3/ws0911_179dfk_rfxwhq6dvr0000gn/T/python-build.20190523131052.99380
Results logged to /var/folders/n3/ws0911_179dfk_rfxwhq6dvr0000gn/T/python-build.20190523131052.99380.log

Last 10 log lines:
  File "/private/var/folders/n3/ws0911_179dfk_rfxwhq6dvr0000gn/T/python-build.20190523131052.99380/Python-3.7.2/Lib/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/private/var/folders/n3/ws0911_179dfk_rfxwhq6dvr0000gn/T/python-build.20190523131052.99380/Python-3.7.2/Lib/ensurepip/__init__.py", line 204, in _main
    default_pip=args.default_pip,
  File "/private/var/folders/n3/ws0911_179dfk_rfxwhq6dvr0000gn/T/python-build.20190523131052.99380/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/n3/ws0911_179dfk_rfxwhq6dvr0000gn/T/python-build.20190523131052.99380/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
   Exiting due to failure

I followed the note but still doesn't work. I'm using macOS v10.14.4.

> ~/Code  echo $LDFLAGS
-L/usr/local/opt/zlib/lib
> ~/Code  echo $CPPFLAGS
-I/usr/local/opt/zlib/include
@rahulrajaram
Copy link
Contributor

@Rokt33r, try brew install zlib prior to exporting the flags.

@Rokt33r
Copy link
Author

Rokt33r commented May 23, 2019

It didn't work for me...:cry:

> brew install zlib
Error: /usr/local/opt/zlib is not a valid keg

@rahulrajaram
Copy link
Contributor

I think /usr/local/opt/zlib might be a broken directory. Try brew unlink zlib and then retry. Otherwise, you might have to manually remove /usr/local/opt/zlib.

@Rokt33r
Copy link
Author

Rokt33r commented May 23, 2019

I remove zlib and install it again. Then I'm seeing another error...

**************************
5. Installing Python 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
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


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

Inspect or clean up the working tree at /var/folders/n3/ws0911_179dfk_rfxwhq6dvr0000gn/T/python-build.20190524011859.54937
Results logged to /var/folders/n3/ws0911_179dfk_rfxwhq6dvr0000gn/T/python-build.20190524011859.54937.log

Last 10 log lines:
			install|*) ensurepip="" ;; \
		esac; \
		 ./python.exe -E -m ensurepip \
			$ensurepip --root=/ ; \
	fi
Looking in links: /var/folders/n3/ws0911_179dfk_rfxwhq6dvr0000gn/T/tmplhx3ogfr
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-18.1 setuptools-40.6.2
   Exiting due to failure

@rahulrajaram
Copy link
Contributor

Looks like openssl is missing as well. Can you retry following a brew install openssl?

rahulrajaram added a commit that referenced this issue May 23, 2019
This release fixes:

1. Issue involving spaces within virtualenv DEST_DIR path ( Issue #20 )
2. Non-determinism involved in choosing Python executable to create
   virtualenv with when multiple Pythons are available on the computer.
3. zlib-related recommendation for OS X in the README ( Issues #22 / #23 )
4. the continuation of the ebcli_installer.py script beyond its failure
   to install the EB CLI.
@rahulrajaram rahulrajaram added the bug Something isn't working label May 23, 2019
@Rokt33r
Copy link
Author

Rokt33r commented May 24, 2019

I'm still getting the same error...

It seems like openssl is already installed in my machine. So I ran brew reinstall openssl again. But nothing is changed.

@rahulrajaram
Copy link
Contributor

This is a standard openssl installation problem on OS X. From the looks of it, it sounds like a linkage issue just as it was with zlib. Some openssl issues are discussed here.

@Rokt33r
Copy link
Author

Rokt33r commented May 30, 2019

Hmm... Do you know where the link should exist? Seems like most of answer is making a link in /usr/local/bin/openssl. So I've tried but I've kept getting the same error.

> ls /usr/local/bin/openssl
/usr/local/bin/openssl

Should I make the link in other place?

@rahulrajaram
Copy link
Contributor

Try:

brew link --force openssl

This should tell you what to link. I see an instruction to export LDFLAGS and CPPFLAGS, but you have to be careful to include not only openssl but also zlib.

@Rokt33r
Copy link
Author

Rokt33r commented May 31, 2019

I tried but it is not working still...

This should tell you what to link. I see an instruction to export LDFLAGS and CPPFLAGS, but you have to be careful to include not only openssl but also zlib.

How can I include both openssl and zlib?

I set LDFLAGS and CPPFLAGS to ~/.zshrc like below.

export LDFLAGS="-L/usr/local/opt/zlib/lib -L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include -I/usr/local/opt/openssl/include"

And I also executed brew link --force openssl before running installer script.

Logs

**************************
5. Installing Python 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
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


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

Inspect or clean up the working tree at /var/folders/n3/ws0911_179dfk_rfxwhq6dvr0000gn/T/python-build.20190531112719.21746
Results logged to /var/folders/n3/ws0911_179dfk_rfxwhq6dvr0000gn/T/python-build.20190531112719.21746.log

Last 10 log lines:
			install|*) ensurepip="" ;; \
		esac; \
		 ./python.exe -E -m ensurepip \
			$ensurepip --root=/ ; \
	fi
Looking in links: /var/folders/n3/ws0911_179dfk_rfxwhq6dvr0000gn/T/tmp494oprmt
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-18.1 setuptools-40.6.2
   Exiting due to failure

==============================================
II. Creating self-contained EBCLI installation
==============================================
aws-elastic-beanstalk-cli-setup/scripts/bundled_installer: line 51: /Users/junyoung/.pyenv/versions/3.7.2/bin/python: No such file or directory
aws-elastic-beanstalk-cli-setup/scripts/bundled_installer: line 28: echo_with_indentation: command not found

@ursulac
Copy link

ursulac commented May 31, 2019

@Rokt33r I also had the zlib error but I was simply able to run brew install awsebcli and it works now (from here https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install-osx.html)

@Rokt33r
Copy link
Author

Rokt33r commented Jun 1, 2019

@ursulac Thanks. But I think we need to deal with this problem, because this project is supposed to replace brew install awsebcli. https://github.com/aws/aws-elastic-beanstalk-cli-setup#43-on-macos-or-linux-systems-with-brew-is-this-better-than-brew-install-awsebcli

@rahulrajaram
Copy link
Contributor

rahulrajaram commented Jun 3, 2019

You get around the Python installation problem by installing Python through other means (e.g. brew install python. Note that usually, OS X comes with a Python 2.7, so you might get away without have to do this). Then:

pip install virtualenv
python ./scripts/ebcli_installer.py

I recommend using the ebcli_installer.py script rather than brew install awsebcli to install the EB CLI precisely for the reasons listed here.

@Rokt33r
Copy link
Author

Rokt33r commented Jun 3, 2019

pip install virtualenv
python ./scripts/ebcli_installer.py

It works for me! Thanks! :)

@Rokt33r Rokt33r closed this as completed Jun 3, 2019
@rahulrajaram
Copy link
Contributor

@Rokt33r , glad that worked.

I'd like to keep this Issue open since, aside from the Open SSL issue, there are minor usability issues that need to be fixed.

@rahulrajaram rahulrajaram reopened this Jun 3, 2019
rahulrajaram added a commit that referenced this issue Jun 6, 2019
A lot of users have reported installation difficulties
owing to absence of OpenSSL, bzip2, etc. This commit
adds a Troubleshooting section to the README for
customers using Ubuntu/Debian, Amazon Linux/Fedora,
and OS X.

Related Issues: #23, #25, #27
rahulrajaram added a commit that referenced this issue Jun 6, 2019
A lot of users have reported installation difficulties
owing to absence of OpenSSL, bzip2, etc. This commit
adds a Troubleshooting section to the README for
customers using Ubuntu/Debian, Amazon Linux/Fedora,
and OS X.

Related Issues: #23, #25, #27
rahulrajaram added a commit that referenced this issue Jun 6, 2019
A lot of users have reported installation difficulties
owing to absence of OpenSSL, bzip2, etc. This commit
adds a Troubleshooting section to the README for
customers using Ubuntu/Debian, Amazon Linux/Fedora,
and OS X.

Related Issues: #23, #25, #27
rahulrajaram added a commit that referenced this issue Jun 7, 2019
A lot of users have reported installation difficulties
owing to absence of OpenSSL, bzip2, etc. This commit
adds a Troubleshooting section to the README for
customers using Ubuntu/Debian, Amazon Linux/Fedora,
and OS X.

Related Issues: #23, #25, #27
@anton-syrovatka
Copy link

I had the same issue with installing python from this script.
This helped me bypass the issue:
brew install pyenv
pyenv install 3.7.2

@NextPageAI
Copy link

I had the same issue with installing python from this script.
This helped me bypass the issue:
brew install pyenv
pyenv install 3.7.2

Thank you, this solved the issue for me 👍

@joben
Copy link

joben commented Jan 8, 2020

I've managed to get past initial error on python by following @anton-syrovatka suggestion.

Now python is throwing

OSError: [Errno 62] Too many levels of symbolic links:

@rahulrajaram
Copy link
Contributor

tl;dr: those of you still facing an issue on OS X with zlib/SSL not being found, consider symlinking to the packages installed by brew from /usr/local.


One other thing to consider if anybody is still facing the issue on a Macs is that when you brew install anything, it typically gets put inside /Library/, whereas a lot of traditional C packages such as CPython expect libraries inside /usr, /usr/local,/usr/local/opt, etc.. This is why when you brew install openssl, you can a note at the end talking about symlinking.

  1. Find the package location of, say, zlib, inside /Library with a command such as:

     find /Library -name "openssl" 2>/dev/null
    
  2. create a symlink to it (note: replace the placeholders <...>):

     sudo ln -s /usr/local/opt/openssl /Library/<path>/openssl<version>
    

In fact, after this, I don't think you will need to export LDFLAGS and CFLAGS.

@msdtim
Copy link

msdtim commented Apr 4, 2020

My solution on Mojave (10.14) is similar to @rahulrajaram , but only link the lib and include folder. For me, the issue is with zlib. You can use the following commands.

brew install zlib

ln -s /usr/local/Cellar/zlib/1.2.11/include/* /usr/local/include

ln -s /usr/local/Cellar/zlib/1.2.11/lib/* /usr/local/lib

I find it easier to just install the pyenv package and install the required python version on my own.

brew install pyenv
pyenv install 3.7.2

Please take note your zlib and python version may vary.

@ludiw823
Copy link

I had the same issue with installing python from this script.
This helped me bypass the issue:
brew install pyenv
pyenv install 3.7.2

Works for me! thanks!

@noecarrasdev
Copy link

@ursulac Thanks. But I think we need to deal with this problem, because this project is supposed to replace brew install awsebcli. https://github.com/aws/aws-elastic-beanstalk-cli-setup#43-on-macos-or-linux-systems-with-brew-is-this-better-than-brew-install-awsebcli

I had the same issues that I couldn't fix. But using homebrew actually allowed me to install it in 2 commands. Thank you !

@Stouffi
Copy link

Stouffi commented Oct 8, 2020

Had same issue and I found this PR #85 which saved my day.

CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib" ./scripts/bundled_installer

You still have to make sure that you have installed openssl readline and zlib with homebrew of course but it was already clearly mentioned.

This PR could be merged to help macOS users.

@zjd2035
Copy link

zjd2035 commented Dec 27, 2020

I was still running into the original issue zipimport.ZipImportError: can't decompress data; zlib not available on MacOS Catalina 10.15.1. The steps so far didn't really help, and directly running python ebcli_installer.py lead me into issues with an eb init error No such file or directory: '/Users/z/.ebcli-virtual-env/bin/eb'

I ended up manually installing python 3.7.3 and setting it as the global python pyenv global 3.7.2.
This included adding the line eval "$(pyenv init -)" to my .bash_profile to get it to be properly observed by python -V.

That solving both the issue with running ./aws-elastic-beanstalk-cli-setup/scripts/bundled_installer and eb init after the fact. Hope this helps!

novasdream added a commit to novasdream/aws-elastic-beanstalk-cli-setup that referenced this issue Jan 5, 2021
@David1845
Copy link

hey guys, had the same problem, zlip library not being found. But if you cloned with Aws-elastic-beanstalk-cli-setup ( git clone https://github.com/aws/aws-elastic-beanstalk-cli-setup.git), and run the file Aws-elastic-beanstalk-cli-setup/scripts/ebcli_installer.py. Ebcli will be installed. But its using EB CLI 3.20.2 (Python 3.9.9), so I am not sure if that will be an issue going forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests