title: ansible can't find a python package even if it is installed
body: <p>Trying to use <code>docker-compose</code> within an ansible playbook using the <code>docker_compose</code> module. Note that I can successfully use the docker module in ansible but running into problems with <code>docker_compose</code> module. I'm using plaintext vars for testing locally, I use ansible-vault for storing secrets.</p>
  <p>On the ansible documentation it explains that their docker-compose module only supports version 1 and 2 of docker-compose.</p>
  <p>Here is my <code>docker-compose.yml</code>:</p>
  <pre class="lang-yaml prettyprint-override"><code>---
  version: &quot;2.4&quot;
  services:
     my_demo:
         build: .
         networks:
            demo_net:
               ipv4_address: 172.0.1.2
         ports:
            - 8080:8080
         image: demo_image
  
  networks:
      demo_net:
         driver: bridge
         ipam:
           driver: default
           config:
             - subnet: 172.0.1.0/30
               gateway: 172.0.1.1
  </code></pre>
  <p>Here is my <code>main.yml</code>:</p>
  <pre class="lang-yaml prettyprint-override"><code>---
  - hosts: localhost
    connection: local
    become: true
  
    vars:
      - ansible_sudo_pass: password
      - ansible_python_interpreter: /usr/bin/python3
  
    tasks:
      - name: Docker compose
        docker_compose:
           project_name: docker_fhe_ansible
           project_src: .
           build: yes
        register: output
  
      - debug:
          var: output
  </code></pre>
  <p>Output:</p>
  <pre><code>PLAY [localhost] **********************************************************************************************************************************************************************************
  
  TASK [Gathering Facts] ****************************************************************************************************************************************************************************
  ok: [localhost]
  
  TASK [Docker compose] *****************************************************************************************************************************************************************************
  fatal: [localhost]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;msg&quot;: &quot;Failed to import the required Python library (Docker SDK for Python: docker (Python &gt;= 2.7) or docker-py (Python 2.6)) on ubuntu's Python /usr/bin/python3. Please read module documentation and install 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, for example via `pip install docker` or `pip install docker-py` (Python 2.6). The error was: No module named 'docker'&quot;}
  
  PLAY RECAP ****************************************************************************************************************************************************************************************
  localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
  </code></pre>
  <p>The error is &quot;no module named docker&quot;, I can verify python3 has the module:</p>
  <pre><code>john@ubuntu:~/Documents/docker-ansible$ python3
  Python 3.8.10 (default, Jun  2 2021, 10:49:15) 
  [GCC 9.4.0] on linux
  Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
  &gt;&gt;&gt; import docker
  &gt;&gt;&gt; import ansible
  </code></pre>