Get your python 3.11.9 back on Linux

First of all, Select the required python version (Example: 3.11.9)

https://www.python.org/ftp/python/3.11.9/

Now, Install all the required dependencies to compile and install Python 3.11.9

sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev

Download and extract 3.11.9 by using wget command.

wget https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tar.xz

Extract it

tar -xf Python-3.11.9.tgz

Configure the build with optimization flags:

cd Python-3.11.9 && ./configure --enable-optimizations

Build Python using multiple processors to speed up the process and Install Python 3.11.9 on your system:

make -j$(nproc) && sudo make altinstall

Check if the python version 3.11 is installed

python3.11 --version

Set Python 3.11 as the Default To conveniently access Python 3.11 using below command

nano ~/.zshrc

Add the following line at the end of the .zshrc file and save it.

alias python3='/usr/local/bin/python3.11'

Also refresh the .zshrc via source comand

source ~/.zshrc

Verify the Default Python Version Check the Python version using the python3 command:

python3 --version