which python
# Output
/usr/bin/python
python --version
# Output
Python 2.7.5
which python3
# Output
/usr/bin/python3
python3 --version
# Output
Python 3.6.8
Step 1: Download the Python Gzipped source file
wget https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tgz
Step 2: Unpack the .tgz file
tar zxvf Python-3.9.7.tgz
Step 3: Navigate to Python-3.9.7 folder
cd Python-3.9.7/
Step 3: Execute configure script
./configure
Step 3: Build the Python3.9 binary
make
Step 4: Install the Python3.9 binary
sudo make altinstall
Step 5: Verify Python3.9 and previous installations
which python3.9
# Output
/usr/local/bin/python3.9
python3.9 --version
# Output
Python 3.9.7
which python3
# Output
/usr/bin/python3
python3 --version
# Output
Python 3.6.8
which python
# Output
/usr/bin/python
python --version
# Output
Python 2.7.5
Category: Python