The correct answer to this question depends on the OS AMI installed.
For this question there are several options to solve this problem:
- Use
python3
because python
(python 2.x) is not installed.
- Install python 2.x (Ubuntu):
sudo apt-get install python
- Execute the command:
sudo ln /usr/bin/python3 /usr/bin/python
to link python
to python3
in the /usr/bin
directory.
Amazon Linux 2 has Python 2.7.14 installed. The commands "python", "python2" and "python2.7" are supported. Python 3 is not installed by default.
Ubuntu 16.04 64-bit has Python 3.5.2 installed. The commands "python3" and "python3.5" are supported. Note that there is no link to "python". Python 2 is not installed by default.
One item that I noticed with Amazon Linux 2 and Python 2.7. The command python -V
writes the version string to stderr, which will make you think that the command failed as the SSM Run Command will display the output as follows when the command actually succeeded. I discovered that the SSM Run Command is just display the stderr after the stdout separated by ----------ERROR-------
----------ERROR-------
Python 2.7.14
Python 3 writes the version string to stdout. This took me hours to figure out as I never noticed the stderr issue with Python 2.x until today.
Information on the AMIs that I tested with.
Region: us-west-2 (Oregon)
Amazon Linux 2:
amzn2-ami-hvm-2.0.20180810-x86_64-gp2 (ami-6cd6f714)
Ubuntu 16.04 LTS:
ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-20180814 (ami-51537029)