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

**URL:** <https://forum.ansible.com/t/ansible-builtin-apt-module-does-not-work-with-installed-python-3-12-on-target-machine/39046>\
**Category:** Get Help\
**Tags:** apt, python, debian\
**Created:** [December 11, 2024, 9:54am UTC](https://forum.ansible.com/t/ansible-builtin-apt-module-does-not-work-with-installed-python-3-12-on-target-machine/39046 "2024-12-11T09:54:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![a531ac0edd70bcea93ad](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/a531ac0edd70bcea93ad/32/6945_2.png) [@a531ac0edd70bcea93ad](https://forum.ansible.com/u/a531ac0edd70bcea93ad)\
**Post date:** [December 11, 2024, 9:54am UTC](https://forum.ansible.com/t/ansible-builtin-apt-module-does-not-work-with-installed-python-3-12-on-target-machine/39046/1 "2024-12-11T09:54:57Z")

</div>

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:

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

```

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

```auto
        "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:

```auto
"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.

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [December 11, 2024, 3:30pm UTC](https://forum.ansible.com/t/ansible-builtin-apt-module-does-not-work-with-installed-python-3-12-on-target-machine/39046/2 "2024-12-11T15:30:09Z")

</div>

Try `pip install python-apt-binary`, based on the [Debian package page](https://packages.debian.org/buster/python3-apt) this is the name of the [PyPi package](https://pypi.org/project/python-apt-binary/).

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

---

<div class="post-metadata">

**Author:** ![a531ac0edd70bcea93ad](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/a531ac0edd70bcea93ad/32/6945_2.png) [@a531ac0edd70bcea93ad](https://forum.ansible.com/u/a531ac0edd70bcea93ad)\
**Post date:** [December 13, 2024, 10:53am UTC](https://forum.ansible.com/t/ansible-builtin-apt-module-does-not-work-with-installed-python-3-12-on-target-machine/39046/3 "2024-12-13T10:53:15Z")

</div>

This package seems not to be available for `Python 3.12.8`

```auto
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.

---

<div class="post-metadata">

**Author:** ![bvitnik](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bvitnik/32/4132_2.png) [@bvitnik](https://forum.ansible.com/u/bvitnik)\
**Post date:** [December 13, 2024, 12:16pm UTC](https://forum.ansible.com/t/ansible-builtin-apt-module-does-not-work-with-installed-python-3-12-on-target-machine/39046/4 "2024-12-13T12:16:21Z")

</div>

> [@a531ac0edd70bcea93ad](#):
>
> 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?
