To resolve the error Failed to import the required Python library (kubernetes) on rfelix-mac's Python /usr/local/opt/[email protected]/bin/python3.11. 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"
I had just to install Kubernetes Python Client like bellow:
➜ pip3 install kubernetes
Collecting kubernetes
Downloading kubernetes-26.1.0-py2.py3-none-any.whl (1.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.4/1.4 MB 385.9 kB/s eta 0:00:00
Collecting certifi>=14.05.14
Downloading certifi-2022.12.7-py3-none-any.whl (155 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 155.3/155.3 kB 382.0 kB/s eta 0:00:00
Requirement already satisfied: six>=1.9.0 in /usr/local/lib/python3.11/site-packages (from kubernetes) (1.16.0)
Collecting python-dateutil>=2.5.3
Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 kB 334.1 kB/s eta 0:00:00
Requirement already satisfied: setuptools>=21.0.0 in /usr/local/lib/python3.11/site-packages (from kubernetes) (65.6.3)
Requirement already satisfied: pyyaml>=5.4.1 in /usr/local/lib/python3.11/site-packages (from kubernetes) (6.0)
Collecting google-auth>=1.0.1
Downloading google_auth-2.16.2-py2.py3-none-any.whl (177 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 177.2/177.2 kB 305.3 kB/s eta 0:00:00
Collecting websocket-client!=0.40.0,!=0.41.*,!=0.42.*,>=0.32.0
Downloading websocket_client-1.5.1-py3-none-any.whl (55 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 55.9/55.9 kB 819.8 kB/s eta 0:00:00
Collecting requests
Downloading requests-2.28.2-py3-none-any.whl (62 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.8/62.8 kB 185.6 kB/s eta 0:00:00
Collecting requests-oauthlib
Downloading requests_oauthlib-1.3.1-py2.py3-none-any.whl (23 kB)
Collecting urllib3>=1.24.2
Downloading urllib3-1.26.15-py2.py3-none-any.whl (140 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 140.9/140.9 kB 188.7 kB/s eta 0:00:00
Collecting cachetools<6.0,>=2.0.0
Downloading cachetools-5.3.0-py3-none-any.whl (9.3 kB)
Collecting pyasn1-modules>=0.2.1
Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 155.3/155.3 kB 137.4 kB/s eta 0:00:00
Collecting rsa<5,>=3.1.4
Downloading rsa-4.9-py3-none-any.whl (34 kB)
Collecting charset-normalizer<4,>=2
Downloading charset_normalizer-3.1.0-cp311-cp311-macosx_10_9_x86_64.whl (123 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 123.7/123.7 kB 142.0 kB/s eta 0:00:00
Collecting idna<4,>=2.5
Downloading idna-3.4-py3-none-any.whl (61 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 151.0 kB/s eta 0:00:00
Collecting oauthlib>=3.0.0
Downloading oauthlib-3.2.2-py3-none-any.whl (151 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 151.7/151.7 kB 158.6 kB/s eta 0:00:00
Collecting pyasn1<0.5.0,>=0.4.6
Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.1/77.1 kB 150.9 kB/s eta 0:00:00
Installing collected packages: pyasn1, websocket-client, urllib3, rsa, python-dateutil, pyasn1-modules, oauthlib, idna, charset-normalizer, certifi, cachetools, requests, google-auth, requests-oauthlib, kubernetes
Successfully installed cachetools-5.3.0 certifi-2022.12.7 charset-normalizer-3.1.0 google-auth-2.16.2 idna-3.4 kubernetes-26.1.0 oauthlib-3.2.2 pyasn1-0.4.8 pyasn1-modules-0.2.8 python-dateutil-2.8.2 requests-2.28.2 requests-oauthlib-1.3.1 rsa-4.9 urllib3-1.26.15 websocket-client-1.5.1
[notice] A new release of pip available: 22.3.1 -> 23.0.1
[notice] To update, run: python3.11 -m pip install --upgrade pip
➜ python3.11 -m pip install --upgrade pip
Requirement already satisfied: pip in /usr/local/lib/python3.11/site-packages (22.3.1)
Collecting pip
Downloading pip-23.0.1-py3-none-any.whl (2.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 11.6 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.3.1
Uninstalling pip-22.3.1:
Successfully uninstalled pip-22.3.1
Successfully installed pip-23.0.1
TASK [install_operator : nexus-operator - Create CatalogSource for use with catalog snapshot] *******************************************************************************************
task path: /Users/rfelix/redhat/projetos/interno/workshop-quarkus/fontes/agnosticd/ansible/roles/install_operator/tasks/install.yml:23
File lookup using /Users/rfelix/redhat/projetos/interno/workshop-quarkus/fontes/agnosticd/ansible/roles/install_operator/templates/catalogsource.yaml.j2 as file
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: rfelix
<localhost> EXEC /bin/sh -c 'echo ~rfelix && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/rfelix/.ansible/tmp `"&& mkdir "` echo /Users/rfelix/.ansible/tmp/ansible-tmp-1678988570.674422-85782-61695740494500 `" && echo ansible-tmp-1678988570.674422-85782-61695740494500="` echo /Users/rfelix/.ansible/tmp/ansible-tmp-1678988570.674422-85782-61695740494500 `" ) && sleep 0'
Loading collection cloud.common from /usr/local/Cellar/ansible/7.3.0/libexec/lib/python3.11/site-packages/ansible_collections/cloud/common
Using module file /usr/local/Cellar/ansible/7.3.0/libexec/lib/python3.11/site-packages/ansible_collections/kubernetes/core/plugins/modules/k8s.py
<localhost> PUT /Users/rfelix/.ansible/tmp/ansible-local-85739qg68iy09/tmpz0qhdahp TO /Users/rfelix/.ansible/tmp/ansible-tmp-1678988570.674422-85782-61695740494500/AnsiballZ_k8s.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/rfelix/.ansible/tmp/ansible-tmp-1678988570.674422-85782-61695740494500/ /Users/rfelix/.ansible/tmp/ansible-tmp-1678988570.674422-85782-61695740494500/AnsiballZ_k8s.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/local/bin/python3.11 /Users/rfelix/.ansible/tmp/ansible-tmp-1678988570.674422-85782-61695740494500/AnsiballZ_k8s.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/rfelix/.ansible/tmp/ansible-tmp-1678988570.674422-85782-61695740494500/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
File "/var/folders/hq/ffzpzjvj7138tq05f12chw3m0000gn/T/ansible_kubernetes.core.k8s_payload_n0xgo_kh/ansible_kubernetes.core.k8s_payload.zip/ansible_collections/kubernetes/core/plugins/module_utils/k8s/core.py", line 107, in requires
requires(dependency, minimum, reason=reason)
File "/var/folders/hq/ffzpzjvj7138tq05f12chw3m0000gn/T/ansible_kubernetes.core.k8s_payload_n0xgo_kh/ansible_kubernetes.core.k8s_payload.zip/ansible_collections/kubernetes/core/plugins/module_utils/k8s/core.py", line 175, in requires
raise Exception(missing_required_lib(lib, reason=reason))
fatal: [localhost]: FAILED! =>
{
"changed": false,
"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,
"continue_on_error": false,
"definition": {
"apiVersion": "operators.coreos.com/v1alpha1",
"kind": "CatalogSource",
"metadata": {
"name": "nexus-operator-catalogsource",
"namespace": "openshift-operators"
},
"spec": {
"displayName": "nexus-operator-catalogsource",
"image": "quay.io/gpte-devops-automation/nexus-catalog:v1.0.0",
"publisher": "Red Hat AgnosticD",
"sourceType": "grpc"
}
},
"delete_options": null,
"force": false,
"generate_name": null,
"host": null,
"impersonate_groups": null,
"impersonate_user": null,
"kind": null,
"kubeconfig": null,
"label_selectors": null,
"merge_type": null,
"name": null,
"namespace": null,
"no_proxy": null,
"password": null,
"persist_config": null,
"proxy": null,
"proxy_headers": null,
"resource_definition": {
"apiVersion": "operators.coreos.com/v1alpha1",
"kind": "CatalogSource",
"metadata": {
"name": "nexus-operator-catalogsource",
"namespace": "openshift-operators"
},
"spec": {
"displayName": "nexus-operator-catalogsource",
"image": "quay.io/gpte-devops-automation/nexus-catalog:v1.0.0",
"publisher": "Red Hat AgnosticD",
"sourceType": "grpc"
}
},
"server_side_apply": null,
"src": null,
"state": "present",
"template": null,
"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 (kubernetes) on rfelix-mac's Python /usr/local/opt/[email protected]/bin/python3.11. 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"
}