'trouble installing Google Cloud SDK in ubuntu

I'm trying to install Google Cloud SDK in ubuntu, but getting an error:

[root@localhost google-cloud-sdk]# ./install.sh

Welcome to the Google Cloud SDK!

File "/home/marilu/google-cloud-sdk/bin/bootstrapping/install.py", line 182

with open(rc_path) as rc_file:

          ^

SyntaxError: invalid syntax [root@localhost google-cloud-sdk]# 

I have installed Python; this is how it looks

[root@localhost marilu]# ls -l

drwxr-xr-x  5 marilu marilu     4096 Apr  8 11:35 google-cloud-sdk

drwxrwxr-x 19 marilu marilu     4096 Apr 23 09:08 Python-2.7.6

[root@localhost marilu]# 

Can someone help me? Why this error?



Solution 1:[1]

1 Download and install Google Cloud SDK by running the following command in your shell or Terminal:

curl https://dl.google.com/dl/cloudsdk/release/install_google_cloud_sdk.bash | bash

2 Restart your shell or Terminal.

3 Authenticate to Google Cloud Platform by running gcloud auth login.

Did you try that?

Solution 2:[2]

As at the time of writing, the install.sh and install.py require Python 2.7, and I have observed a similar error when the default/system Python is version 3+. You can confirm that by running python --version.

You have several ways to work around this:

  1. Set an environment variable to tell install.sh which python to use, i.e. add the following line to ~/.bashrc:

export CLOUDSDK_PYTHON=/path/to/python2.7

Then source ~/.bashrc and rerun install.py

or 2. Create a python2.7 Virtual Environment, activate it, and then run install.sh

You can find the location of the installed python2.7 executable by running which python2.7.

Solution 3:[3]

echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -

sudo apt update

sudo apt-get install google-cloud-sdk

gcloud init

Solution 4:[4]

You can use apt-get to install the Cloud SDK in an Ubuntu/DebĂ­an System.

Solution 5:[5]

Install google cloud SDK by running the single command:

sudo apt-get install apt-transport-https ca-certificates gnupg && echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - && sudo apt-get update && sudo apt-get install google-cloud-sdk && sudo apt-get install google-cloud-sdk-app-engine-java && sudo apt-get install google-cloud-sdk-app-engine-python && gcloud init

Hope your issue will be resolved.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Samantha
Solution 2 Chris
Solution 3 Antier Solutions
Solution 4 MonicaPC
Solution 5 Md. Shahariar Hossen