Gsutil: Can't run gsutil on Mac Catalina

Created on 24 Jan 2020  路  12Comments  路  Source: GoogleCloudPlatform/gsutil

For some reason, with no changes I'm aware of on my system since I last used gsutil, I can no longer run gsutil on my Mac (running Catalina 10.15.2 (19C57)). Just typing gsutil at the command line yields the following stack trace. I have updated the Google Cloud SDK to the latest version (277.0.0) with no errors (by running gcloud components update). I also tried gcloud components reinstall. I am properly authenticated via gcloud and I can run commands using gcloud without issue. Any help would be appreciated.

Traceback (most recent call last):
  File "/usr/local/google-cloud-sdk/platform/gsutil/gsutil", line 21, in <module>
    gsutil.RunMain()
  File "/usr/local/google-cloud-sdk/platform/gsutil/gsutil.py", line 123, in RunMain
    import gslib.__main__
  File "/usr/local/google-cloud-sdk/platform/gsutil/gslib/__main__.py", line 68, in <module>
    from google_reauth import reauth_creds
  File "/usr/local/google-cloud-sdk/platform/gsutil/third_party/google-reauth-python/google_reauth/reauth_creds.py", line 23, in <module>
    from oauth2client import client
  File "/usr/local/google-cloud-sdk/platform/gsutil/third_party/oauth2client/oauth2client/client.py", line 45, in <module>
    from oauth2client import crypt
  File "/usr/local/google-cloud-sdk/platform/gsutil/third_party/oauth2client/oauth2client/crypt.py", line 45, in <module>
    from oauth2client import _openssl_crypt
  File "/usr/local/google-cloud-sdk/platform/gsutil/third_party/oauth2client/oauth2client/_openssl_crypt.py", line 16, in <module>
    from OpenSSL import crypto
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL/crypto.py", line 12, in <module>
    from cryptography import x509
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography/x509/__init__.py", line 8, in <module>
    from cryptography.x509.base import (
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography/x509/base.py", line 16, in <module>
    from cryptography.x509.extensions import Extension, ExtensionType
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography/x509/extensions.py", line 24, in <module>
    from cryptography.x509.general_name import GeneralName, IPAddress, OtherName
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography/x509/general_name.py", line 16, in <module>
    from cryptography.x509.name import Name
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography/x509/name.py", line 28, in <module>
    _ASN1_TYPE_TO_ENUM = dict((i.value, i) for i in _ASN1Type)
TypeError: 'type' object is not iterable

Most helpful comment

It works!!
Just export CLOUDSDK_PYTHON=python3 if you have multiple python interpreters installed! :-)
Thanks @dilipped

All 12 comments

I have run into the same problem

Can you please run this command and paste the output here?

gsutil version -l

My guess is that your enum package is out of date. I see similar issue here: https://github.com/pyca/cryptography/issues/4020

Can you please run this command and paste the output here?

gsutil version -l

this gives the same error.....

I will try an update my enum package and let you know :-)

so my primitive investigations show me that enum34 is the package that is required, which is not compatible with python 3.7, and given that conda is my package manager, it raises conflicts, and doesnt allow me to install. So is there a fix for this problem using conda itself?

@Burple-ML post python3.4, enum is part of the standard lib https://docs.python.org/3/library/enum.html
So if you are using python3.7, this should work fine and you need not install any package, but looking at your stack trace above, it looks like you are using python2.7?

No! I am using python 3.7 !

From your stack trace:

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography/x509/name.py

It has 2.7 in the path.

Ohh! missed that! How do i point google-cloud-SDK to the right python environment?
I want to avoid removing python 2.7 which seems to be the ideal solution as mentioned in the issue: https://github.com/pyca/cryptography/issues/4020

i think this is the solution:-https://cloud.google.com/sdk/gcloud/reference/topic/startup

It works!!
Just export CLOUDSDK_PYTHON=python3 if you have multiple python interpreters installed! :-)
Thanks @dilipped

Closing this issue as the problem was because of the enum library in python2.7. For python2.7 follow the resolutions discussed here https://github.com/pyca/cryptography/issues/4020. For Python3, this should not be an issue. Feel free to re-open the issue if the problem persists.

Was this page helpful?
0 / 5 - 0 ratings