Ansible.builtin.apt module does not work with installed Python 3.12 on target machine

I have an older Debian machine running Debian 10. This machine has installed Python 3.7.3. I cannot upgrade this machine to a newer version, need to wait for the company to release an upgrade.

I upgraded my ansible installation to the latest 2.18.1 and the old Python version on the target machine is now not supported anymore.

I compiled Python 3.12.8 and installed it using make altinstall.
Additionally I set the variable ansible_python_interpreter for this machine in the inventory accordingly:

ansible_python_interpreter: /usr/local/bin/python3.12

Other modules running fine, self installed Python version is used, output of ansible.builtin.setup:

        "ansible_python": {
            "executable": "/usr/local/bin/python3.12",
            "has_sslcontext": true,
            "type": "cpython",
            "version": {
                "major": 3,
                "micro": 8,
                "minor": 12,
                "releaselevel": "final",
                "serial": 0
            },
            "version_info": [
                3,
                12,
                8,
                "final",
                0
            ]
        }

ansible.builtin.apt indeed throws the following error:

"ansible-core requires a minimum of Python version 3.8. Current version: 3.7.3 (default, Nov 23 2024, 16:31:22) [GCC 8.3.0]"

I think it’s because of the missing python3-apt module in my alternative Python installation.

How can I install python3-apt into my self-compiled Python 3.12.8? I tried pip, but this package is somehow not even existing.

Try pip install python-apt-binary, based on the Debian package page this is the name of the PyPi package.

Or do what I have done — decide to stick with Ansible 2.17.x until all Debian Buster servers have been upgraded or destroyed!

This package seems not to be available for Python 3.12.8

pip3.12 install python-apt-binary
ERROR: Could not find a version that satisfies the requirement python-apt-binary (from versions: none)
ERROR: No matching distribution found for python-apt-binary

It’s a pity that the apt module has this dependency. :-/

Sticking with 2.17.x is not really an option because just of one machine being outdated.

Why not? Why is 2.18.x a necessity?

1 Like