Search code examples
pythonlinuxinstallationgcloudamazon-linux

Can't install gcloud on Amazon Linux : invalid syntax


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.


Solution

  • 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.