# for docker
apt install software-properties-common
add-apt-repository ppa:deadsnakes/ppa
apt install python3.8
# the answer is given by Merwanski for linux:
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.8
python3.8 --version
# you could also simply go to: https://www.python.org/downloads/ and find your preferred version.
# install it for your OS.
sudo yum -y install wget
wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz