Skip to content
Advertisement

sudo yum install is giving weird error on AWS Linux ec2 (SyntaxError: invalid syntax)

Machine details:

Cloud: AWS

OS: Linux ip-10-196-64-140.eu-west-1.compute.internal 4.14.209-160.335.amzn2.x86_64 #1 SMP Wed Dec 2 23:31:46 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Error details:

[ec2-user@ip-<hostip> ~]$ sudo yum install java-11-amazon-corretto-headless
  File "/bin/yum", line 30
    except KeyboardInterrupt, e:
                            ^
SyntaxError: invalid syntax

Advertisement

Answer

I tried to reproduce the issue, and it fails when you run yum with python3 instead of python2:

python3 /usr/bin/yum install java-11-amazon-corretto-headless
  File "/usr/bin/yum", line 30
    except KeyboardInterrupt, e:
                            ^
SyntaxError: invalid syntax

You should use python2, not python3 for yum:

python2 /usr/bin/yum install java-11-amazon-corretto-headless

It seems that in your instance default python version was changed to python3.

1 People found this is helpful
Advertisement