4

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 !

Tran B. V. Son
  • 759
  • 2
  • 12
  • 31
  • 2
    Possible duplicate of [no module named zlib](https://stackoverflow.com/questions/6169522/no-module-named-zlib) – ikkentim Jan 24 '19 at 10:12
  • Same here. gcloud started to fail (not only the installation but also running the existing version) after upgrading Python with brew yesterday for me. – ahmet alp balkan Mar 07 '19 at 21:08

2 Answers2

1

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.

Alesso
  • 183
  • 2
  • 8
1

Install Developer Command Line Tools :

xcode-select --install

Reinstall python2 :

brew reinstall python2    
jota3
  • 5,389
  • 2
  • 13
  • 22