Install Python 3.8 on Ubuntu version 24
To install Python 3.8 on Ubuntu version 24
Open your terminal and run these commands:
Install build dependencies
sudo apt-get update
sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm \
libncurses5-dev libncursesw5-dev xz-utils tk-dev \
libffi-dev liblzma-dev python3-openssl git
Download and extract Python 3.8 source code
mkdir ~/python38
cd ~/python38
wget https://www.python.org/ftp/python/3.8.16/Python-3.8.16.tgz
tar -xf Python-3.8.16.tgz
cd Python-3.8.16
Configure the build
./configure --enable-optimizations
Compile the source code
make -j$(nproc)
Install Python
sudo make install
Verify the installation
python3.8 --version
To create a virtual environment specify the Python version.
Example: python3.8 -m venv venv