<p>The env</p>

<blockquote>
  <p>Ansible 2.9.6 (python3)</p>
</blockquote>

<p>Tried to run a simple playbook</p>

<pre><code>- hosts: master
  gather_facts: no
  become: yes
  tasks:
    - name: create name space
      k8s:
        name: testing
        api_version: v1
        kind: Namespace
        state: present
</code></pre>

<p>Getting following error</p>

<pre><code>The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_k8s_payload_u121g92v/ansible_k8s_payload.zip/ansible/module_utils/k8s/common.py", line 33, in &lt;module&gt;
    import kubernetes
ModuleNotFoundError: No module named 'kubernetes'
fatal: [192.168.20.38]: FAILED! =&gt; {
    "changed": false,
    "error": "No module named 'kubernetes'",
    "invocation": {
        "module_args": {
            "api_key": null,
            "api_version": "v1",
            "append_hash": false,
            "apply": false,
            "ca_cert": null,
            "client_cert": null,
            "client_key": null,
            "context": null,
            "force": false,
            "host": null,
            "kind": "Namespace",
            "kubeconfig": null,
            "merge_type": null,
            "name": "testing",
            "namespace": null,
            "password": null,
            "proxy": null,
            "resource_definition": null,
            "src": null,
            "state": "present",
            "username": null,
            "validate": null,
            "validate_certs": null,
            "wait": false,
            "wait_condition": null,
            "wait_sleep": 5,
            "wait_timeout": 120
        }
    },
    "msg": "Failed to import the required Python library (openshift) on k8smasternode'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"
}

</code></pre>

<p>It confuses me that, </p>

<ul>
<li>the root cause is <strong>"no module named kubernetes"</strong>?</li>
<li>or <strong>"Failed to import the required Python library (openshift) on Python /usr/bin/python3"</strong>?</li>
</ul>

<p>And how to fix that? </p>

<p>Any help would be appreciated!</p>

<p>btw, </p>

<blockquote>
  <p><strong>Kubernetes master node has /usr/bin/python3</strong></p>
</blockquote>

Hua
<p>I am a bit late to the party but since I faced this today and don't see an accepted answer, I am posting what worked for me.</p>
<p>Since you are running the tasks on remote servers, you must have <code>openshift</code>, <code>pyyaml</code> and <code>kubernetes</code> installed on the remote machines for this to work.</p>
<p>Add below tasks prior to creating namespaces:</p>
<pre><code>- name: install pre-requisites
  pip:
    name:
      - openshift
      - pyyaml
      - kubernetes 
</code></pre>
