Bootstrap FreeKB - Ansible - Resolve "Failed to import the required Python library"
Ansible - Resolve "Failed to import the required Python library"

Updated:   |  Ansible articles

Let's say the following is being returned.

fatal: [server1.example.com]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on server1.example.com's Python /usr/bin/python. 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 'requests'"}

 

On the target syste, determine if Python 2.x.x or 3.x.x is being used.

~]$ /usr/bin/python --version
Python 3.9.12

 

If running Python version 2.7 or higher, use pip install to install the Python docker module.

pip3 install docker

 

If not root, you may need to run this command using sudo as well.

sudo pip3 install docker

 

If running Python version 2.6 or below, use pip to install docker-py.

pip3 install docker-py

 

If not root, you may need to run this command using sudo as well.

sudo pip3 install docker-py

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter ce48f0 in the box below so that we can be sure you are a human.