Download the desired Python version at this address: https://www.python.org/downloads/source/
Move the downloaded archive to a safe location as you may need to recompile Python several times and unzip the file using:
tar -xvzf <file>Before installing Python, you might need to install some dependencies, check it before or you might need to recompile everything. If something is missing, you should see it in the compilation logs.
You then need to configure using the command:
./configure --enable-shared --enable-optimizationsSome additional flags might be added if needed.
Finally you can compile using:
makeand then:
sudo make altinstallWhen recompiling, use the following command to clean the installation:
make clean