Bootstrap FreeKB - Ansible - Resolve "ModuleNotFoundError: No module named 'ansible.module_utils.six.moves'"
Ansible - Resolve "ModuleNotFoundError: No module named 'ansible.module_utils.six.moves'"

Updated:   |  Ansible articles

Let's say something like this is being returned.

ModuleNotFoundError: No module named 'ansible.module_utils.six.moves'

 

I first saw this when attempting to run and older version of Ansible on a target system that was running a newer version of Python. The ansible ad-hoc command can be used to list the version of Ansible, the location of the Ansible configuration file, and the version of Python being used by the Ansible controller. Something like this should be returned.

~]# ansible --version
ansible [core 2.12.1]
  config file = None
  configured module search path = ['/home/john.doe/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/ansible-core/v2_12_1/lib/python3.12/site-packages/ansible
  ansible collection location = /home/john.doe/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.12.0 (main, Dec 22 2023, 02:43:27) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] (/usr/local/ansible-core/v2_12_1/lib/python3.12)
  jinja version = 3.1.3
  libyaml = True

 

On the target system, the python --version command can be used to list the version of Python being used on the target system.

~]# python --version
Python 2.7.5

 

On the target system, the python3 --version command can be used to list the version of Python3 being used on the target system.

~]# python3 --version
Python 3.12.0

 

The following URL lists the versions of Python that are supported by a certain version of ansible-core. For example, ansible-core version 2.12 is compatible with Python version 3.5 through 3.10. 

https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html

The "ModuleNotFoundError: No module named 'ansible.module_utils.six.moves'" error may be returned if the version of ansible-core does not support the version of Python on the target systems.

 




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 623a0b in the box below so that we can be sure you are a human.