Install Python 3.9 on Raspberry Pi OS or Debian 10 (for Ansible or other uses)
I've started getting a lot of bug reports on my repos to the effect of "Ansible won't install on my Raspberry Pi anymore". Accompanying it is a debug message like one of the following:
$ python3 -m pip install ansible
...
No matching distribution found for ansible-core<2.13,>=2.12.0 (from ansible)
# Alternatively:
ERROR: No matching distribution found for ansible-core<2.13,>=2.12.0
The problem is ansible-core
2.12 has a new hard requirement for Python 3.8 or newer. And ansible-core
2.12 is included in Ansible 5.0.0, which was recently released. Raspberry Pi OS, which was based on Debian 10 ("Buster") until recently, includes Python 3.7, which is too old to satisfy Ansible's installation requirements.
There was recently a fix that makes it so Ansible 5.x won't get installed on these older systems, but who wants to get stuck on old unsupported Ansible versions?
There are three options: