0
votes

I am running a script on EC2 based on ami-0130c3a072f3832ff 2018.03 version.

In the list of preinstalled packages there is python-boto3

But when I try to import boto3 it says No module named: boto3

How can I resolve this issue?

Note: There is a problem, in this situation I can't use the internet (I would have used pip if this was possible)

EDIT1:

EDIT2: I am starting a EC2 instance to run the script on startup and shut down after the execution.

instance = EC2.run_instances(
    ImageId=AMI,
    InstanceType=INSTANCE_TYPE,
    MinCount=1,
    MaxCount=1,
    InstanceInitiatedShutdownBehavior='terminate',
    UserData=script
)

The script is written in Python and begins with #!/usr/bin/env python

1
Are you using a particular version of python? Boto3 may be installed for 2.7 and not 3 or vice versa.Spicy Meatball
By the way, that is an instance-store backed AMI. Are you choosing that intentionally for any reason?John Rotenstein
How did you view the "list of preinstalled packages"? I launched the AMI and couldn't find boto3 on it.John Rotenstein
I've looked up here for packages: aws.amazon.com/amazon-linux-ami/2018-03-packagesljmocic
I choose it accidentally since I thought that in my case it wouldn't matter if it is ebs-backed or instance store.ljmocic

1 Answers

0
votes

You need to install pip and boto3 from the packages available through amazon AMI.

sudo yum install python-pip python3-wheel && Pip install boto3 --user

  • @ljmocic