I wanted to run ansible with python3, but the output of ansible version still shows python 2 version, even if I pass ansible_python_interpreter
#ansible-playbook --version -e 'ansible_python_interpreter=/usr/bin/python3'
ansible-playbook 2.9.27
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible-playbook
python version = 2.7.5 (default, xxxx, xx:xx:xx) [GCC 4.8.5 2015xx (Red Hat 4.8.5-44)]
How to force ansible to use python 3?
When I do win_ping I get the below error
"msg": "winrm or requests is not installed: No module named winrm"
Checking winrm and requests:
# python3
Python 3.6.8 (default, xx xx 2023, 08:41:09)
[GCC 4.8.5 2015xxx (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import winrm
>>> import requests
>>>
I was able to make it work after running the below commands.
update-alternatives --config python3
pip3 --version
python3 -m ensurepip --upgrade
pip3 --version
pip3 install pywinrm
hash -r
pip3 install pywinrm