google cloud sdk: set environment variable_ python

2019-05-07 12:39发布

ERROR: Python 3 is not supported by the Google Cloud SDK.  Please use a Python 2.x version that is 2.6 or greater.

If you have a compatible Python interpreter installed, you can use it by setting the CLOUDSDK_PYTHON environment variable to point to it.

I guess the first question we should be asking is "with all the money google makes off of their customers why can't they hire someone to ensure that their cloud sdk works with python 3?"

How exactly to overcome this error on linux? What specific files need to be edited? and where should those files be located?

I searched around, a lot, and found this question about how to fix this on Windows, but the answer is not really that comprehensive.


Thus far I've attempted:

One source of documentationsays to modify a file called app.yaml, but I searched using the command find . -name "app.yaml" and no such file exists.

Specifically I'm using arch linux, I originally tried to use the AUR package but it's disfunctional.

So I installed from the documentation, making sure to edit the ./install.sh file, specifying python2 as per this discussion on the google groups, that doesn't work either. after running the command gcloud auth login I get the same error as posted above.

3条回答
祖国的老花朵
2楼-- · 2019-05-07 13:18

This is a very easy thing to solve. The native python command on the Arch command line is actually for Python 3. The SDK requires Python2.7 and the

  • Just go to the google-cloud-sdk folder and open the install.sh file.

  • Change the CLOUDSDK_PYTHON="python" value to CLOUDSDK_PYTHON="python2.7"

  • Rerun the install with the command

    ./install.sh
    in the same folder and follow the prompts.

That's all.

查看更多
不美不萌又怎样
3楼-- · 2019-05-07 13:21

I see this almost every time I update gcloud SDK, especially when running dev_appserver.py <my app config yaml file>

I found that setting the CLOUDSDK_PYTHON env variable to 'python2' seems to silence the error. E.g on macOS:

export CLOUDSDK_PYTHON=python2

Not sure why they simply cannot make this dev server compatible with Python 3 already

查看更多
\"骚年 ilove
4楼-- · 2019-05-07 13:22

I had the same issue so I did a little change in the dev_appserver.py
change the shebang #!/usr/bin/env python --> #!/usr/bin/env python2

查看更多
登录 后发表回答