title: Failed to import the required Python library (botocore or boto3)
body: <p>I'm running a playbook on localhost, and I've already installed ansible and the required packaged like boto3. The playbook works fine when it is performing tasks on a remote host, but outputs the following error when running locally.</p>
  <p>Command:</p>
  <pre><code>ansible-playbook app.yaml
  </code></pre>
  <p>Error:</p>
  <pre><code>fatal: [localhost]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;msg&quot;: &quot;Failed to import the required Python library (botocore or boto3) on DESKTOP-9NTDHK1's Python /usr/bin/python3. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter&quot;}
  </code></pre>
  <p>Ansible version:</p>
  <pre><code>ansible 2.10.3
    config file = /home/user/ansible/ansible.cfg
    configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
    ansible python module location = /home/user/ansible/venv/lib/python3.8/site-packages/ansible
    executable location = /home/user/ansible/venv/bin/ansible
    python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
  </code></pre>
  <p>Boto3 version:</p>
  <pre><code>(venv) user@DESKTOP-9NTDHK1:~/ansible$ pip show boto3ersion&quot;
  Name: boto3
  Version: 1.16.18
  Summary: The AWS SDK for Python
  Home-page: https://github.com/boto/boto3
  Author: Amazon Web Services
  Author-email: UNKNOWN
  License: Apache License 2.0
  Location: /home/user/ansible/venv/lib/python3.8/site-packages
  Requires: s3transfer, botocore, jmespath
  Required-by:
  </code></pre>
  <p>app.yaml</p>
  <pre class="lang-yaml prettyprint-override"><code>---
  - hosts: localhost
    connection: local
    gather_facts: no
    vars:
      user: *****
      AWS_PREFIX: *****
      
    tasks:
      
      # provision AWS
      
      - name: Provision VPC
        ec2_vpc_net:
          cidr_block: *****
          region: *****
          name: *****
          state: present
        register: vpc_data
  </code></pre>