2

I'm trying to install gcloud on my EC2 server running Amazon Linux 4.14.47-56.37 64bits, in interactive mode running the following command :

curl https://sdk.cloud.google.com | bash

The files download correctly, but the install then fails with the following Traceback :

  File "/home/ec2-user/google-cloud-sdk/bin/bootstrapping/install.py", line 12, in <module>
    import bootstrapping
  File "/home/ec2-user/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 32, in <module>
    import setup  # pylint:disable=g-import-not-at-top
  File "/home/ec2-user/google-cloud-sdk/bin/bootstrapping/setup.py", line 55, in <module>
    from googlecloudsdk.core import properties
  File "/home/ec2-user/google-cloud-sdk/lib/googlecloudsdk/core/properties.py", line 291
    self.__sections = {section.name: section for section in sections}
                                               ^
SyntaxError: invalid syntax

Any idea why this for is causing issues?

I am running python 2.7 (2.7.14) as recommended by Google.

4

5 回答 5

2

On top of python 2.7 installed on the "python" command, I also had python 2.6 installed on the "python2" command. Uninstalling python 2.6 solved the issue, Google Cloud install went through without issue on the next try.

于 2018-06-22T19:55:10.040 回答
2

You locally update the install.sh file to use python2.7 instead of python2. This worked for me

于 2018-09-14T18:42:07.707 回答
2

In case someone meets this problem again, and if you do not want to uninstall python 2.6 or to modify install.sh, here is a procedure that worked for me on an ec2 instance :

open a new terminal and type :

curl https://sdk.cloud.google.com | bash

The install should not work as CLOUDSDK_PYTHON=python2 by default, which leads to Python 2.6. To correct this, enter this command :

export CLOUDSDK_PYTHON=python

this links CLOUDSDK_PYTHON to Python 3.6

then

bash google-cloud-sdk/install.sh

and finally

./google-cloud-sdk/bin/gcloud init

Once this is done, you can use any gcloud or gsutil command by doing this :

./google-cloud-sdk/bin/gcloud <your gcloud command>
./google-cloud-sdk/bin/gsutil <your gsutil command>

For example, in order to copy a folder from a gs bucket to your ec2 instance :

./google-cloud-sdk/bin/gsutil -m cp -r gs://<bucket_name>/path/to/folder /path/on/your/ec2/instance

the -m option allows fast transfer (I could transfer with an average speed of 81 MiB/s with this option)

Hope this helps !

于 2020-05-14T14:49:07.900 回答
1

Setup yum repo:

# Update YUM with Cloud SDK repo information:
sudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo << EOM
[google-cloud-sdk]
name=Google Cloud SDK
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
       https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOM
# The indentation for the 2nd line of gpgkey is important.

Install yum downloader and download the rpm, then install with "--nodeps":

yum install yum-utils
yumdownloader google-cloud-sdk-231.0.0-1.el7.noarch
mv 23873bd6e8459ba6e70e96eb8f03f6ac03cd707ce3c80baa8264c714e030c915-google-cloud-sdk-231.0.0-1.el7.noarch.rpm /usr/local/src/google-cloud-sdk-231.0.0-1.el7.noarch
rpm -ivh --nodeps /usr/local/src/google-cloud-sdk-231.0.0-1.el7.noarch
于 2019-01-29T11:05:17.403 回答
0

This solved issue:

export CLOUDSDK_PYTHON=python
于 2020-10-12T16:34:49.827 回答