ansible, python,

Ansible change Python interpreter

Jul 04, 2022 · 1 min read · Post a comment

If you are getting this kind of warning:

[DEPRECATION WARNING]: Distribution Ubuntu on host should use
/usr/bin/python3, but is using /usr/bin/python for backward compatibility with prior Ansible releases

And some of your Ansible playbooks are throwing errors regarding the issue you should consider updating your Python interpreter.


  • Ansible
  • Python 3


Step 1. If you want to execute an Ansible playbook from the CLI, then you can change the Python interpreter directly.

ansible-playbook --vvv -e 'ansible_python_interpreter=/usr/bin/python3'

Step 2. If you want to put it on a config level, you can set the path in ansible.cfg or create ansible_python_interpreter_inventory.yml inventory variable at your group or host level.

    ansible_python_interpreter: /usr/bin/python3


Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.