I recently installed Python 3.5 64-bit on Windows 7. Now while trying to install Google Cloud SDK I am getting following error:

Output folder: C:\Program Files (x86)\Google\Cloud SDK
Downloading Google Cloud SDK core.
Extracting Google Cloud SDK core.
Create Google Cloud SDK bat file: C:\Program Files (x86)\Google\Cloud SDK\cloud_env.bat
Installing components.
Welcome to the Google Cloud SDK!
  File "C:\Python\Lib\site.py", line 176
SyntaxError: invalid syntax
  File "C:\Python\Lib\site.py", line 176
SyntaxError: invalid syntax
Failed to install.

I haven't modified any of the Python Lib files.


I don't think the Google Cloud SDK can run on Python 3 (the system requirements state that Python 2.7.x is required).

There is a 'bundled python' option in step 5 of the windows GUI installer (after you choose the installation path) if you need to quickly install a Python 2.7 just for these tools.

Google Cloud Installer Step 5]

Note that it is only the CLI tools that require Python 2.7. The python API libraries google-api-python-client [1] and gcloud-python [2] will work with python 3.5. So depending on what you are doing, you can still use Python 3 in your projects.

[1] From the google-api-python-client README.md

Python 3.3+ is also now supported! However, this library has not yet been used as thoroughly with Python 3, so we'd recommend testing before deploying with Python 3 in production.

[2] Listed under Python 3 categories on PyPi

  • Thanks @zenlambda, where do I look for "bundled python" option? – Rajat Shah Apr 10 '16 at 3:03
  • @RajatShah I updated the answer with a screenshot and more details of where you can find the "bundled python" option. – Frank Wilson Apr 10 '16 at 7:44
  • strange, that error occurs exaclty with bundled python to me – netalex Jun 27 '16 at 16:34

This happens when GoogleCloud SDK doesn't find an executable python.exe. It downloads python27 by itself, but existing installations of more recent versions of python (such as 3x), and the corresponding Environment Variables will continue to interfere.

Thus, the best practice would be to:

  • Download and install Python 2.7 at any desired location, say C:\Program Files\Python27
  • Now add a new Environment Variable named CLOUDSDK_PYTHON, and set its value to the location of the python.exe from the installation above.

    • In my case, it would be "C:\Program Files\Python27\python.exe"
  • Now re-run the setup.

  • If the problem still exists, add python 2.7 to your PYTHONPATH & Path Environment Variables(system).
  • After adding, move them UP, above any other python3x variables using the Move Up (Win10), or just paste the paths before any other python 3x variable.

This will ensure that your system always prioritizes python2.7 over any other version. To check if python2.7 is properly added, type in cmd

 python -v

This will tell you the version of python interpreter currently used.

  • You should make it clearer that CLOUDSDK_PYTHON indeed must contain full path to the python executable + "python.exe". But you solved my problem so a big thanks to you! – Overdrivr Apr 13 '17 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.