Kevin
Kevin

Reputation: 5082

Gcloud sdk install for Mac

I have an issue to install the gcloud sdk on my mac. I have the following error when I do the ./install.sh. Source: https://cloud.google.com/sdk/docs/quickstart

Welcome to the Google Cloud SDK!
Traceback (most recent call last):
  File "/Users/kevin/Downloads/google-cloud-sdk/bin/bootstrapping/install.py", line 12, in <module>
    import bootstrapping
  File "/Users/kevin/Downloads/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 32, in <module>
    import setup  # pylint:disable=g-import-not-at-top
  File "/Users/kevin/Downloads/google-cloud-sdk/bin/bootstrapping/setup.py", line 57, in <module>
    from googlecloudsdk.core.util import platforms
  File "/Users/kevin/Downloads/google-cloud-sdk/lib/googlecloudsdk/__init__.py", line 23, in <module>
    from googlecloudsdk.core.util import importing
  File "/Users/kevin/Downloads/google-cloud-sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module>
    import imp
  File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/imp.py", line 23, in <module>
    from importlib import util
  File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/importlib/util.py", line 2, in <module>
    from . import abc
  File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/importlib/abc.py", line 17, in <module>
    from typing import Protocol, runtime_checkable
  File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/typing.py", line 26, in <module>
    import re as stdlib_re  # Avoid confusion with the re we export.
  File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/re.py", line 124, in <module>
    import enum
  File "/Users/kevin/Downloads/google-cloud-sdk/lib/third_party/enum/__init__.py", line 26, in <module>
    spec = importlib.util.find_spec('enum')
AttributeError: module 'importlib' has no attribute 'util'

And when I do gcloud init

Traceback (most recent call last):
  File "/Users/kevin/Downloads/google-cloud-sdk/lib/gcloud.py", line 104, in <module>
    main()
  File "/Users/kevin/Downloads/google-cloud-sdk/lib/gcloud.py", line 62, in main
    from googlecloudsdk.core.util import encoding
  File "/Users/kevin/Downloads/google-cloud-sdk/lib/googlecloudsdk/__init__.py", line 23, in <module>
    from googlecloudsdk.core.util import importing
  File "/Users/kevin/Downloads/google-cloud-sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module>
    import imp
  File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/imp.py", line 23, in <module>
    from importlib import util
  File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/importlib/util.py", line 2, in <module>
    from . import abc
  File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/importlib/abc.py", line 17, in <module>
    from typing import Protocol, runtime_checkable
  File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/typing.py", line 26, in <module>
    import re as stdlib_re  # Avoid confusion with the re we export.
  File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/re.py", line 124, in <module>
    import enum
  File "/Users/kevin/Downloads/google-cloud-sdk/lib/third_party/enum/__init__.py", line 26, in <module>
    spec = importlib.util.find_spec('enum')
AttributeError: module 'importlib' has no attribute 'util'

I think this is a Python issue. but I'm running Python3:

python -V shows

Python 3.9.0

I have installed it with homebrew.

What can be the problem?

Upvotes: 5

Views: 3885

Answers (3)

Daniel Tello
Daniel Tello

Reputation: 639

If you want a quick fix you can add this to your bash profile and restart your terminal:

export CLOUDSDK_PYTHON=python3.8

Worked for me

Upvotes: 5

Puteri
Puteri

Reputation: 3789

This is a known issue across Mac, Windows and Linux: https://issuetracker.google.com/170125513.

I'd suggest to use the recommended Python versions mentioned here (3.5 to 3.8).

Also this does not affect only to Cloud SDK but others as well (for example as mentioned here).

Upvotes: 5

Kevin
Kevin

Reputation: 5082

Thanks for your answer. Indeed, it works with the version 3.8.6 of python. I will add some infos if it can help somebody. In order to manage python version, I have used pyenv and installed the version of python I needed.

pyenv install 3.8.6
pyenv global 3.8.6

Upvotes: 2

Related Questions