Why Getting an Error"winrm or requests is not installed: No module named xmltodict" with Ansible Engine Managing Windows Hosts?

Solution Verified - Updated -


  • Ansible Engine


  • Unable to interface with Windows hosts on a new Ansible control host.


  • Install package :

    # pip install "pywinrm>=0.2.2"

Please Note: You need to run the Windows provisioning PowerShell script on the windows host to configure winrm for Ansible. Please refer to our documentation: Windows System Preparation.

Root Cause

Diagnostic Steps

  • Run the below command :

    # ansible windows -i hosts -m win_ping
    x.x.x.x | FAILED! => {
       "msg": "winrm or requests is not installed: No module named xmltodict"

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.


This solution also handles the python module called winrm (instead of xmldict)

winrm or requests is not installed: No module named winrm

thinkred1cartoon:$ ansible all -i hosts.txt -m win_ping | FAILED! => {
    "msg": "winrm or requests is not installed: cannot import name certs"

I was getting this error even if python2-winrm version 0.3.0 is already installed via yum

yum list installed | grep winrm
python2-winrm.noarch              0.3.0-1.el7                @epel

pip install "pywinrm>=0.2.2" only resulted in "Requirement already satisfied"

I ran this to resolve the error - 

1)     yum autoremove python2-winrm.noarch

2)    pip install "pywinrm>=0.2.2"

Then ping: pong worked just fine over https, port=5986

ram@thinkred1cartoon$ ansible all -i hosts.txt -m win_ping | SUCCESS => {
    "changed": false,
    "ping": "pong"

conversely, if you don't want to run command 1, then command 2 won't work for you. 
In that case, run command 3

3 ) pip install --ignore-installed "pywinrm>=0.2.2"

ram@thinkred1cartoon$ cat hosts.txt           #A quick peek into the inventory file