# How can I make Ansible use newer python due to errors when running playbook under other version?

**URL:** <https://forum.ansible.com/t/how-can-i-make-ansible-use-newer-python-due-to-errors-when-running-playbook-under-other-version/4521>\
**Category:** Get Help\
**Tags:** python\
**Created:** [March 22, 2024, 5:58pm UTC](https://forum.ansible.com/t/how-can-i-make-ansible-use-newer-python-due-to-errors-when-running-playbook-under-other-version/4521 "2024-03-22T17:58:51Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Denney-tech](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/denney-tech/32/1556_2.png) [@Denney-tech](https://forum.ansible.com/u/Denney-tech)\
**Post date:** [March 22, 2024, 7:23pm UTC](https://forum.ansible.com/t/how-can-i-make-ansible-use-newer-python-due-to-errors-when-running-playbook-under-other-version/4521/2 "2024-03-22T19:23:46Z")

</div>

RHEL 8.9 has python3.6, 3.8, 3.9, and 3.11 available to it. It uses `alternatives` to set the priority on them, and `pip3` inherits whatever `python3` is set to. Since you’re not enforcing a version, it’s apparently defaulting to python3.6 and pip3 is installing based on that.

Possible solutions:

1. Be more specific in your installation versions. `dnf install -y python3.11-pip && pip3.11 install -U ansible`
2. Update your alternatives: `dnf install -y python3.11-pip && update-alternatives --set python3 /usr/bin/python3.11 && pip3 install -U ansible`
3. Install EPEL and use the ansible-core version provided by AppStream `dnf install -y ansible` # this is what I do, but EPEL is tailored and provided through Satellite Content Views instead of installing epel-release.

---

_[View the full topic](https://forum.ansible.com/t/how-can-i-make-ansible-use-newer-python-due-to-errors-when-running-playbook-under-other-version/4521)._
