sudo yum install <package-name> is giving weird error on AWS Linux ec2 (SyntaxError: invalid syntax)

sudo yum install <package-name> is giving weird error on AWS Linux ec2 (SyntaxError: invalid syntax)

机器详情:

云:AWS

OS: Linux ip-10-196-64-140.eu-west-1.compute.internal 4.14.209-160.335.amzn2.x86_64 #1 SMP 12 月 2 日星期三 23:31:46 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

错误详情:

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

我试图重现问题,但当你 运行 yum 改为 python3 时失败了共 python2:

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

yum 应该使用python2,而不是python3:

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

看来在您的实例中 默认 python 版本已更改为 python3.