Like stated in this question, my system broke too, when i tried to remove multiple versions of python installed. I now want to keep only one installation, that is the latest one, and also to be able to not have confusions making virtual envs and to install packages to always a single python version and not deal with legacy and lot more reasons. I want to retain only one python version, which is python 3.9. How do I do this without breaking my system?
This is how many python versions I have installed on my 20.04 ubuntu 64-bit desktop.
naveen@naveen-hp:~$ whereis python3
python3: /usr/bin/python3 /usr/bin/python3.8 /usr/bin/python3.9 /usr/lib/python3 /usr/lib/python3.8 /usr/lib/python3.9 /etc/python3 /etc/python3.8 /etc/python3.9 /usr/local/lib/python3.8 /usr/local/lib/python3.9 /usr/include/python3.8 /usr/share/python3 /usr/share/man/man1/python3.1.gz
naveen@naveen-hp:~$ whereis python
python: /usr/bin/python3.8 /usr/bin/python3.9 /usr/lib/python3.8 /usr/lib/python3.9 /usr/lib/python2.7 /etc/python3.8 /etc/python3.9 /usr/local/lib/python3.8 /usr/local/lib/python3.9 /usr/include/python3.8
Short answer you cannot.
There are several reasons, e.g. that different Python versions are not backwards compatible. E.g. Python 3.9 has changed some APIs, so code which ran on Python 3.8 does not necessarily run on Python 3.9.
And the pre-installed Python interpreter is necessary to run system code. E.g. apt, your package installer, is written in Python.
So, please don't even try :-)