4

I get this error message when running install.bat (or install.sh through 'bash' shell) of google-cloud-sdk. Python is version 3.6.

Any suggestions?

diman82
  • 702
  • 8
  • 11

3 Answers3

5

You need Python 2.7 to use gcloud, as described in https://cloud.google.com/sdk/docs/#windows.

On windows you can choose to use "bundled python" option in which case gcloud will use its own version of python 2.7 without interfering with your installed version.

cherba
  • 8,681
  • 3
  • 27
  • 34
2

There is a new reason for this error after a recent upgrade to Google Cloud SDK 303.0.0; gcloud (the start script in sdk/bin) prefers python3 and detects it and uses it (on MacOS), but that error shows. Just use the following line until Google has fixed the problem:

export CLOUDSDK_PYTHON="python2"

Another reason can be that the variable PYTHONPATH is set incorrectly. Try: unset PYTHONPATH before starting python.

Nicholas Franceschina
  • 6,009
  • 6
  • 36
  • 51
cat
  • 2,871
  • 1
  • 23
  • 28
0

Ensure two things:

  1. While installing the GoogleCloudSDK, check the 'BundledPython' option. It will install both python and python3.

  2. Make sure your environment variable-PYTHONPATH is pointing to the directory having the python.exe file.

This worked out for me.

ANKUR SATYA
  • 219
  • 3
  • 10