Tran B. V. Son
Tran B. V. Son

Reputation: 839

"ImportError: No module named zlib" when install google cloud sdk

I'm installing google cloud sdk on mac following this documentation. But I failed when trying to run this command:

$ curl https://sdk.cloud.google.com | bash

And this is error:

Welcome to the Google Cloud SDK!
Traceback (most recent call last):
  File "/Users/tran.ba.vinh.son/google-cloud-sdk/bin/bootstrapping/install.py", line 12, in <module>
    import bootstrapping
  File "/Users/tran.ba.vinh.son/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 44, in <module>
    from googlecloudsdk.core.credentials import store as c_store
  File "/Users/tran.ba.vinh.son/google-cloud-sdk/lib/googlecloudsdk/core/credentials/store.py", line 32, in <module>
    from googlecloudsdk.core import http
  File "/Users/tran.ba.vinh.son/google-cloud-sdk/lib/googlecloudsdk/core/http.py", line 31, in <module>
    from googlecloudsdk.core import http_proxy
  File "/Users/tran.ba.vinh.son/google-cloud-sdk/lib/googlecloudsdk/core/http_proxy.py", line 26, in <module>
    import httplib2
  File "/Users/tran.ba.vinh.son/google-cloud-sdk/lib/third_party/httplib2/__init__.py", line 18, in <module>
    from httplib2.python2.httplib2 import *
  File "/Users/tran.ba.vinh.son/google-cloud-sdk/lib/third_party/httplib2/python2/httplib2/__init__.py", line 35, in <module>
    import gzip
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gzip.py", line 9, in <module>
    import zlib
ImportError: No module named zlib

I tried with Homebrew but same error:

brew cask install google-cloud-sdk

And even after install zlib via brew install zlib. I still got that error. Please help me if you have any suggestions, thanks a lot !

Upvotes: 4

Views: 1082

Answers (2)

jota3
jota3

Reputation: 5756

Install Developer Command Line Tools :

xcode-select --install

Reinstall python2 :

brew reinstall python2    

Upvotes: 1

Alesso
Alesso

Reputation: 183

I found this comment on homebrew core that fixed it for me.

TL;DR -> sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

I had this issue when installing asdf as well. I ran the command above and then brew install asdf worked. I think this issue happens after a macOS update because I had to run it again to install google-cloud-sdk.

Upvotes: 1

Related Questions