2

I am currently trying to install google cloud sdk on my macbook. I am using scikit-learn and anaconda for machine learning so on my laptop python points to python3.5. However google cloud sdk requires python 2.7 for installation, and that's why I am facing the problem of not be able to install it.

when I ran the install.sh file the error occurred and I have no clue how to deal with it:

Adam | ~ $ git/google-cloud-sdk/install.sh
Welcome to the Google Cloud SDK!
Traceback (most recent call last):
  File "/Users/AdamLiu/Git/google-cloud-sdk/lib/third_party/enum/__init__.py", line 364, in __getattr__
    return cls._member_map_[name]
KeyError: '_convert'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/AdamLiu/git/google-cloud-sdk/bin/bootstrapping/install.py", line 8, in <module>
    import bootstrapping
  File "/Users/AdamLiu/Git/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 9, in <module>
    import setup
  File "/Users/AdamLiu/Git/google-cloud-sdk/bin/bootstrapping/setup.py", line 34, in <module>
    from googlecloudsdk.core.util import platforms
  File "/Users/AdamLiu/Git/google-cloud-sdk/lib/googlecloudsdk/core/util/platforms.py", line 18, in <module>
    import platform
  File "/Users/AdamLiu/anaconda/lib/python3.5/platform.py", line 117, in <module>
    import sys, os, re, subprocess
  File "/Users/AdamLiu/anaconda/lib/python3.5/subprocess.py", line 364, in <module>
    import signal
  File "/Users/AdamLiu/anaconda/lib/python3.5/signal.py", line 8, in <module>
    _IntEnum._convert(
  File "/Users/AdamLiu/Git/google-cloud-sdk/lib/third_party/enum/__init__.py", line 366, in __getattr__
    raise AttributeError(name)
AttributeError: _convert

Super thanks in advance!

1 Answer 1

9

Set the CLOUDSDK_PYTHON environment variable to the location of your Python 2.x executable before running install.sh.

Or make sure that you have python2 in your path so that which python2 can find it.

Sign up to request clarification or add additional context in comments.

4 Comments

Hi thanks for replying. But I still don't quite understand how to do it. Is it ok for you to explain it more specifically?
I found a solution to this problem: Not working when python points python3, does it mean I need to create another file named gcloud.workaround and paste the code in it and execute gcloud again? Thanks in advance.
Do you have Python 2.x installed? If not, install it. If it installs as /usr/bin/python2 (or python2 elsewhere on your PATH) then you don't need to do anything else because the install.sh script (read it, it's pretty simple) does a 'which python2' and will find it. Otherwise set the environment variable CLOUDSDK_PYTHON to point at the python 2.x executable via export CLOUDSDK_PYTHON=<location-of-python2>.
Also worth noting that the bundled install doesn't set CLOUDSDK_PYTHON, so if you were to change your path at some point in the future, the sdk will break unless you've set this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.