This install method is tested on:

  • Ubuntu 20.04 and 22.04
  • RaspberryOs
  • Debian 11

To install python from source execute next commands:

Current version: 3.10.7

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


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

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

make -j <nr of cores>
sudo make altinstall