Rather than Default Python 3.10.6, install another Python version:
1. install prerequisite
sudo apt update -y
sudo apt upgrade -y
sudo apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev -y
2. prepare installer
cd ~/Downloads
curl -O https://www.python.org/ftp/python/3.8.9/Python-3.8.9.tar.xz
tar -xf Python-3.8.9.tar.xz
cd Python-3.8.9
3. configure the python build
./configure --enable-optimizations
4. compile and install python
sudo make -j $(nproc)
sudo make altinstall
5. If it is successful, you can check the version
python3.8 --version
6.Set the newly installed Python version
sudo update-alternatives --install /usr/bin/python3.8.9 python3.8.9 /usr/local/bin/python3.8 1
7. update pip
python3.8.9 -m ensurepip --default-pip
python3.8.9 -m pip install --upgrade pip
8. If you want to remove it
sudo rm /usr/local/bin/python3.8
sudo rm /usr/local/bin/pip3.8
sudo rm -rf /usr/local/lib/python3.8
sudo update-alternatives --remove python /usr/local/bin/python3.8