# Ansible not working after python version upgrade

**URL:** <https://forum.ansible.com/t/ansible-not-working-after-python-version-upgrade/4359>\
**Category:** Get Help\
**Tags:** al2, amazon-linux-2, python, playbook, aws, ansible-core\
**Created:** [March 13, 2024, 3:59pm UTC](https://forum.ansible.com/t/ansible-not-working-after-python-version-upgrade/4359 "2024-03-13T15:59:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheRojam](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/therojam/32/475_2.png) [@TheRojam](https://forum.ansible.com/u/TheRojam)\
**Post date:** [March 13, 2024, 3:59pm UTC](https://forum.ansible.com/t/ansible-not-working-after-python-version-upgrade/4359/1 "2024-03-13T15:59:33Z")

</div>

I tried to update the underlying python. I reinstalled `ansible-core` via `pip3` and tried to run an ansible playbook:

```auto
$ ansible-playbook -i ansible_inventory.ini playbooknme.yaml --checkmode
ERROR! Unexpected Exception, this is probably a bug: module 'ansible.constants' has no attribute 'CONTROLLER_PYTHON_WARNING'
the full traceback was:

Traceback (most recent call last):
  File "/usr/local/bin/ansible-playbook", line 76, in <module>
    if C.CONTROLLER_PYTHON_WARNING and not _PY38_MIN:
AttributeError: module '' has no attribute 'CONTROLLER_PYTHON_WARNING'

```

Sadly, its an Amazon Linux 2, which only has python 3.8 in its repositories packages, which I installed.  
I already removed the system Ansible version, which aws provided.  
But that’s not working. Maybe smb here has an idea, what to do.

---

<div class="post-metadata">

**Author:** ![Dustin](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dustin/32/2573_2.png) [@Dustin](https://forum.ansible.com/u/Dustin)\
**Post date:** [March 13, 2024, 11:55pm UTC](https://forum.ansible.com/t/ansible-not-working-after-python-version-upgrade/4359/2 "2024-03-13T23:55:32Z")

</div>

There’s a similar closed issue over on the [Ansible github](https://github.com/ansible/ansible/issues/76416).

The discussion over there implies this is a broken python or ansible installation, and mentions a conflict between the system python and user python environments.

Something I learned is don’t mess with system python environments. Instead, install whatever version of python you want to use and then make a virtual environment of the python version you want.

That will allow you to isolate a lot of python dependencies and requirements to just that virtual environment.
