title: ModuleNotFoundError - How do I install Python3 packages so my my user-data script get's executed?
body: <p>I am trying to run a python script in EC2 user-data. The EC2 instance I am launching uses a custom AMI image that I repaired. I installed the 2 packages that I need - <code>boto3</code> and <code>pyodbc</code> packages by executing these commands (notice, I am installing those as <code>root</code>):</p>
  <pre><code>sudo yum -y install boto3 pyodbc 
  </code></pre>
  <p>My user-data script:</p>
  <pre><code>#!/bin/bash
  set -e -x
  
  # set AWS region
  echo &quot;export AWS_DEFAULT_REGION=${region}&quot; &gt;&gt; /etc/profile
  source /etc/profile
  # copy python script from the s3 bucket
  aws s3 cp s3://${bucket_name}/ /home/ec2-user --recursive
  
  /usr/bin/python3 /home/ec2-user/my_script.py
  </code></pre>
  <p>After launching a new EC2 Instance (using the my custom AMI) and checking <code>/var/log/cloud-init-output.log</code> I see that error:</p>
  <pre><code>+ python3 /home/ec2-user/main_rigs_stopgap.py
  Traceback (most recent call last):
    File &quot;/home/ec2-user/my_script.py&quot;, line 1, in &lt;module&gt;
      import boto3
  ModuleNotFoundError: No module named 'boto3'
  util.py[WARNING]: Failed running /var/lib/cloud/instance/scripts/part-001 [1]
  cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
  util.py[WARNING]: Running module scripts-user (&lt;module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python2.7/site-packages/cloudinit/config/cc_scripts_user.pyc'&gt;) failed
  </code></pre>
  <p>Any suggestions, please?</p>