Ansible troubleshooting — VMware Failed to Import PyVmomi

Let’s troubleshoot together the Ansible fatal error “Failed to import the required Python library (PyVmomi)” to find the root cause, install the required library using PIP, and successfully run our Ansible For VMware Playbook code.

Ansible Pilot
5 min readMay 12, 2022


Today we’re going to talk about Ansible troubleshooting, specifically about the “Failed to import the required Python library (PyVmomi)” message and enable Ansible For VMware.

This fatal error message happens when we are trying to execute some code against your VMware Infrastructure without the necessary Python SDK for the VMware vSphere API.

These circumstances are usually related to the configuration of your Ansible Controller node and usually are not related to Ansible Playbook.

I’m Luca Berton and welcome to today’s episode of Ansible Pilot.


The best way of talking about Ansible troubleshooting is to jump in a live demo to show you practically the “Failed to import the required Python library (PyVmomi)” and how to solve it!

In this demo, I’m going to reproduce the error and fix using the PIP, the Python Package Manager on a demo machine.

error execution

$ ansible-playbook -i inventory vm_info.ymlPLAY [info vm demo] *******************************************************************************TASK [include_vars] *******************************************************************************
ok: [localhost]
TASK [get VM info] ********************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'pyVim'
fatal: [localhost]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"}, "changed": false, "msg": "Failed to import the required Python library (PyVmomi) on



Ansible Pilot

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday