You changed the default system-wide python3 version ...
Each Ubuntu release has a default version of
python3 for system-wide use ... This default version must not be changed by the user as Ubuntu relies heavily on python and most applications are written/maintained with the default python version in mind ... For example gnome-terminal (3.44.0-1ubuntu1) in Ubuntu 22.04(Jammy) depends on python3 (3.10.4-0ubuntu2)(This might get minor version automatic updates from the official release-specific repositories during the release life but shouldn't be altered manually by the user)
Undo what you have done ...
Boot into the live USB(Like the one you used to install Ubuntu) Ubuntu system and select Try Ubuntu then connect to Internet(might be needed if installing/upgrading packages) from the live system and open a terminal then follow these steps:
sudo fdisk -l
And identify your original system's root
/ partition on the HDD. It could be something like
/dev/sda1 then mount it to
/mnt like so:
sudo mount /dev/sda1 /mnt/
sudo mount --bind /proc/ /mnt/proc/
sudo mount --bind /sys/ /mnt/sys/
sudo mount --bind /dev/ /mnt/dev/
sudo cp /etc/resolv.conf /mnt/etc/resolv.conf
sudo chroot /mnt/
Now you are in your original system on the hard disk with a working terminal and Internet connection ... Run whatever command/s you need to fix the system-wide python3 and change it back to the original release default version.
If this does not work, you'll probably need to reinstall Ubuntu.
If you get to the point where nothing worked and you decided to reinstall Ubuntu, make sure you backup all your important data to an external disk first.
Also to minimize loosing your settings, copy your home directory(i.e.
/home/username/) with all its hidden directories and files to an external disk then copy it back again after the new install. This will keep most of your settings for applications i.e. Firefox, Thunderbird... etc but you will need to reinstall applications and packages you manually installed again for that to work.
Never change the default system-wide python3 version again ... You might however use other python versions on your system to run your own projects/code either by using the executable python binary file directly or in a virtual environment ... Please see:
sudo chroot /mnt/step, just run your commands to revert to original system python and then just exit and unmount and reboot.