How To Install Python On Ubuntu How To Install Python On Ubuntu

How To Install Python On Ubuntu 24.04 LTS

How To Install Python On Ubuntu

In this python installation tutorial, we will guide you through the tutorial to install Python on Ubuntu 23.10|22.04|20.04|18.04. We will be installing Python 3.13 on Ubuntu.

How To Install Python On Ubuntu 24.04 LTS

If you want to install the stable version, you can install Python 3.10 as the Python 3.13 is the pre-release version.

Tutorial To Install Python on Ubuntu from Source

At first, You need to install the required dependencies.

sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev

Now build Python 3.12 from the source. Run the following command to download the latest release version of Python from the Python official release page.

wget https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tgz
tar -xf Python-$VERSION.tgz

Run the configure script to check the required dependencies by browsing into the the directory where you have extracted the downloaded file.

cd  Python-$VERSION/
./configure --enable-optimizations

Now run the following command to  initiate the Python 3.12 build process . You need to figure out the number of cores that your system has as the -j argument should match the number of cores on your system for the process to be faster.

make -j $(nproc)

Run the make command below to install Python 3.12 on Ubuntu.

sudo make altinstall

Verify your installation.

$python3.12 --version

Install Python on Ubuntu 24.04 LTS using PPA

In this method, we will install Python on Ubuntu using PPA. Before installing Python, Run the following command to update your Ubuntu and to install the required packages.

sudo apt update && sudo apt upgrade -y

Install required dependency by running the following command.

sudo apt install software-properties-common -y

Now run the following command to add the deadsnakes PPA.

sudo add-apt-repository ppa:deadsnakes/ppa

Press Enter to continue to the next step.

Now install Python 3.10 by running the following command below.

sudo apt install python3.10

Verify the installation of python is successful by running the following command in Ubuntu.

python3.10 --version

Leave a Reply

Your email address will not be published. Required fields are marked *