Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sudo yum install <package-name> 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

like image 341
Amit Meena Avatar asked Apr 01 '26 04:04

Amit Meena


1 Answers

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.

like image 120
Marcin Avatar answered Apr 02 '26 21:04

Marcin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!