Search code examples
pythonamazon-web-servicesboto3amazon-systems-manager

AWS Run Command : Python Not Found


I am using Boto3 SSM to run commands in my instance.

When I run simple command such as echo hello world or mkdir abc it works fine and gives me expected output. but when I am trying to run python -V or any other python command. The output is python not found. But python is in my EC2 Instance which is running Ubuntu. When I manually check it works fine.

Code:

ssm = boto3.client('ssm' ) 
commands = ['python -V']

ssm.send_command(DocumentName="AWS-RunShellScript", Parameters={'commands': commands}, InstanceIds=['i-xxxxxxxxxxx'])

Solution

  • Using python3 worked. Another thing to mention, it uses the core python in the system and does not recognise any other version installed.