Ubuntu install python from source

To install python from source (on my current 21.04) ubuntu distro execute next commands:

sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev libncurses-dev libgdbm-dev libz-dev tk-dev libsqlite3-dev libreadline-dev liblzma-dev libffi-dev libgdbm-compat-dev

wget https://www.python.org/ftp/python/3.9.<x>/Python-3.9.<x>.tgz

tar -xf Python-3.9.<x>.tgz

cd Python-3.9.<x>
./configure --enable-optimizations

make -j <nr of cores>
sudo make altinstall