[Fixed] ModuleNotFoundError: No module named 'ansible_collections.ansible.builtin' – Ansible

by
Ali Hasan
ansible azure-pipelines python-3.x

Quick Fix: To resolve ‘ModuleNotFoundError: No module named ‘ansible_collections.ansible.builtin”, install the ansible.builtin collection with either pip install ansible-base or ansible-galaxy collection install ansible.builtin. This will make the built-in modules available within your Ansible environment, eliminating the error.

The Problem:

A user is trying to run a local Ansible playbook using the ansible.executor module but encounters a ModuleNotFoundError: No module named 'ansible_collections.ansible.builtin'. Despite having installed the ansible package, the ansible_collections package is missing. The missing module is located in /usr/local/lib/python3.11/site-packages/ansible_collections/ansible, but there is no builtin subdirectory. The user is unable to find a way to install the missing module.

The Solutions:

Solution 1: Install missing collections

The issue arises due to the missing `ansible.builtin` collection. To resolve it, you can either install the `ansible-base` package, which includes the required collection, or install the `ansible.builtin` collection specifically using the `ansible-galaxy collection install` command. After the collection is installed, the error should be resolved.

Q&A

What can I do to solve this problem?

Install missing ‘ansible.builtin’ package.

Video Explanation:

The following video, titled "No Module Named Requests FIXED - Pycharm or Komodo edit ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

Pycharm and Komodo edit fixed. Learn More at https://onlinecodecoaching.com DONT CLICK THIS if you don't like us: ...