This is not tested, but an idea to restore python3 functionality when no valid version of Python 3 is in /usr/bin.
Many other answers here tell the user to use apt, but if no valid version of python3 exists, it can be impossible to use apt.
Instead, you could first try to install the necessary Python 3 packages with dpkg. The below commands apply to Ubuntu 22.04 / AMD64, may be different for other versions and architectures:
First download all packages:
wget \
http://mirrors.kernel.org/ubuntu/pool/main/p/python3.10/python3.10_3.10.12-1~22.04.5_amd64.deb \
http://security.ubuntu.com/ubuntu/pool/main/p/python3.10/libpython3.10_3.10.12-1~22.04.5_amd64.deb \
http://mirrors.kernel.org/ubuntu/pool/main/p/python3.10/libpython3.10-stdlib_3.10.12-1~22.04.5_amd64.deb \
http://mirrors.kernel.org/ubuntu/pool/main/p/python3.10/python3.10-minimal_3.10.12-1~22.04.5_amd64.deb \
http://mirrors.kernel.org/ubuntu/pool/main/p/python3.10/libpython3.10-minimal_3.10.12-1~22.04.5_amd64.deb
Then install the downloaded packages with:
sudo dpkg -i \
./python3.10_3.10.12-1~22.04.5_amd64.deb \
./libpython3.10_3.10.12-1~22.04.5_amd64.deb \
./libpython3.10-stdlib_3.10.12-1~22.04.5_amd64.deb \
./python3.10-minimal_3.10.12-1~22.04.5_amd64.deb \
./libpython3.10-minimal_3.10.12-1~22.04.5_amd64.deb
This will hopefully restore basic python3 functionality.
Afterwards, to fix things completely do:
sudo apt install --reinstall --fix-broken python3