ansible-navigator
ansible-navigator copied to clipboard
ansible-navigator 24.3.2 attempts to load python 3.9 library instead of 3.12 when inspecting EE images
ISSUE TYPE
- Bug Report
SUMMARY
Encountering issue using ansible-navigator to display the Ansible collections within an execution environment:
ImportError: cannot import name 'TypeAlias' from 'typing' (/usr/lib64/python3.9/typing.py)
The environment is Fedora 40, ansible-navigator 24.3.2.
Workaround: downgrade to ansible-navigator 24.2.0.
ANSIBLE-NAVIGATOR VERSION
ansible-navigator 24.3.2
CONFIGURATION
---
ansible-navigator:
execution-environment:
pull:
policy: missing
playbook-artifact:
enable: false
logging:
file: ~/ansible-navigator.log
...
LOG FILE
2024-05-16T21:18:03.410409+00:00 ERROR 'ansible_navigator.actions.images._parse' Unable to extract introspection from stdout
2024-05-16T21:18:03.412977+00:00 ERROR 'ansible_navigator.actions.images._parse' Image introspection failed (parsed), the return value was: Traceback (most recent call last):
File "/home/jdickerson/.cache/ansible-navigator/image_introspect.py", line 16, in <module>
from typing import TypeAlias
ImportError: cannot import name 'TypeAlias' from 'typing' (/usr/lib64/python3.9/typing.py)
STEPS TO REPRODUCE
OS: Fedora 40
- "# python3 -m pip install ansible-navigator --user"
- use podman pull to download any execution environment image
- run "# ansible-navigator images"
- select an execution environment image
- Select Option 2 in order to inspect the Ansible collections.
- Receive error
- Escape back to the shell and review your ansible-navigator.log file
EXPECTED RESULTS
I expect to see the list of Ansible collections with their versions.
ACTUAL RESULTS
I receive an error message that something went really wrong, and find the following in the ansible-navigator.log
2024-05-16T21:18:03.410409+00:00 ERROR 'ansible_navigator.actions.images._parse' Unable to extract introspection from stdout
2024-05-16T21:18:03.412977+00:00 ERROR 'ansible_navigator.actions.images._parse' Image introspection failed (parsed), the return value was: Traceback (most recent call last):
File "/home/jdickerson/.cache/ansible-navigator/image_introspect.py", line 16, in <module>
from typing import TypeAlias
ImportError: cannot import name 'TypeAlias' from 'typing' (/usr/lib64/python3.9/typing.py)
ADDITIONAL INFORMATION
Only workaround is to downgrade to ansible-navigator 24.2.0
Please remove the cache first and also provide more information about which python interpreter is used to execute navigator.
This is a good find. Can you confirm the python version inside the EE? The image_introspect.py is volume mounted into the EE and run there to introspect it.
I cleared the ansible-navigatgor cache using "# rm ~/.cache/ansible-navigator/*" and tried again. I received the same result.
On Fedora 40 I am using the default python 3.12.
I have several EE's I can inspect:
quay.io/ansible/awx-ee:latest (inspection fails) (python 3.9) ghcr.io/ansible/creator-ee:v24.2.0 (works) (python 3.12) registry.redhat.io/ansible-automation-platform-24/ee-29-rhel8:latest (inspection fails) (python 3.8) registry.redhat.io/ansible-automation-platform-24/ee-minimal-rhel8:latest (inspection fails) (python 3.9) registry.redhat.io/ansible-automation-platform-24/ee-supported-rhel8:latest (inspection fails) (python 3.9)
So it seems to depend on what python is in the EE. if the EE contains python 3.12 it works, 3.8 and 3.9 do not. Notice the OS I'm running on runs 3.12 as well.
If I downgrade to ansible-navigator==24.2.0 inspection works for all of the EE's regardless of the python version.
Python information by EE:
awx-ee:
bash-5.1$ python --version
Python 3.9.18
bash-5.1$ ls -l /usr/bin/python*
lrwxrwxrwx. 1 root root 9 Jan 26 18:40 /usr/bin/python -> ./python3
lrwxrwxrwx. 1 root root 9 Jan 26 18:30 /usr/bin/python3 -> python3.9
-rwxr-xr-x. 1 root root 15624 Jan 26 18:30 /usr/bin/python3.9
bash-5.1$
creator-ee:
root@creator-ee:v24.2.0: /tmp
# python --version
Python 3.12.1
root@creator-ee:v24.2.0: /tmp
# ls -l /usr/bin/python*
lrwxrwxrwx. 1 root root 9 Dec 18 00:00 /usr/bin/python -> ./python3
lrwxrwxrwx. 1 root root 16 Dec 18 00:00 /usr/bin/python-config -> ./python3-config
lrwxrwxrwx. 1 root root 10 Dec 18 00:00 /usr/bin/python3 -> python3.12
lrwxrwxrwx. 1 root root 17 Dec 18 00:00 /usr/bin/python3-config -> python3.12-config
-rwxr-xr-x. 1 root root 15888 Dec 18 00:00 /usr/bin/python3.12
-rwxr-xr-x. 1 root root 62 Dec 18 00:00 /usr/bin/python3.12-config
-rwxr-xr-x. 1 root root 3079 Dec 18 00:00 /usr/bin/python3.12-x86_64-config
root@creator-ee:v24.2.0: /tmp
#
ee-29-rhel8:
bash-4.4# python --version
Python 3.8.17
bash-4.4# ls -al /usr/bin/python*
lrwxrwxrwx. 1 root root 36 Apr 18 2023 /usr/bin/python -> /etc/alternatives/unversioned-python
lrwxrwxrwx. 1 root root 25 Apr 18 2023 /usr/bin/python3 -> /etc/alternatives/python3
-rwxr-xr-x. 1 root root 7776 Aug 10 2023 /usr/bin/python3.8
bash-4.4#
ee-minimal-rhel8:
bash-4.4# python --version
Python 3.9.18
bash-4.4# ls -al /usr/bin/python*
lrwxrwxrwx. 1 root root 36 Apr 18 17:04 /usr/bin/python -> /etc/alternatives/unversioned-python
lrwxrwxrwx. 1 root root 25 Apr 18 17:04 /usr/bin/python3 -> /etc/alternatives/python3
-rwxr-xr-x. 1 root root 7768 Sep 22 2023 /usr/bin/python3.9
bash-4.4#
ee-supported-rhel8:
bash-4.4# python --version
Python 3.9.18
bash-4.4# ls -al /usr/bin/python*
lrwxrwxrwx. 1 root root 36 Apr 18 17:04 /usr/bin/python -> /etc/alternatives/unversioned-python
lrwxrwxrwx. 1 root root 25 Apr 18 17:04 /usr/bin/python3 -> /etc/alternatives/python3
-rwxr-xr-x. 1 root root 7768 Sep 22 2023 /usr/bin/python3.9
bash-4.4#
I can also Confirm this, tested on RHEL 8. When using the latest ansible-navigator version this wont work, downgrade to said version fixes this.
This seems to be happening on RHEL 9 with ansible-navigator 24.9.0 as well. The default Python on the machine is 3.9.
The log excerpt from the last ansible-navigator when I'm trying to get system or Python packages from within the interface:
KeyError: 'system'
2025-01-22T15:51:34.194565+00:00 ERROR 'ansible_navigator.actions.images._parse' Unable to extract introspection from stdout
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/ansible_navigator/actions/images.py", line 537, in _parse
_warnings, json_str = output.split("{", 1)
^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)
2025-01-22T15:51:34.195796+00:00 ERROR 'ansible_navigator.actions.images._parse' Image introspection failed (parsed), the return value was: Traceback (most recent call last):
File "/home/jwilliams/.cache/ansible-navigator/image_introspect.py", line 16, in <module>
from typing import TypeAlias
ImportError: cannot import name 'TypeAlias' from 'typing' (/usr/lib64/python3.9/typing.py)
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/ansible_navigator/actions/images.py", line 537, in _parse
_warnings, json_str = output.split("{", 1)
^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)
Seems like a classic function signature mismatch, the type that occurs when you have mixed versions of Python.