Python is a powerful programming language that is widely used by developers for a variety of tasks, from web development to data analysis. If you’re using Ubuntu or another Linux distribution and want to install the latest version of Python, you’re in luck – it’s a straightforward process that can be completed in just a few steps.
In this article, we’ll walk you through how to install Python 3.13 on Ubuntu and other Linux distros.
Step 1: Update your package list
Before you begin, it’s a good idea to update your package list to ensure you have the latest versions of all software packages. Open a terminal and run the following command:
sudo apt update
Step 2: Install necessary dependencies
Next, you’ll need to install some dependencies that Python requires in order to build and run properly. Run the following command to install these packages:
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev curl
Step 3: Download the latest version of Python
Head to the official Python website (https://www.python.org/downloads/) and find the latest version of Python. At the time of writing, Python 3.13 is the latest stable release. Copy the link to the source code tarball.
Back in the terminal, use the curl command to download the tarball to your system. Replace the URL in this command with the link to the Python 3.13 tarball:
curl -O https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz
Step 4: Extract the source code
After the download is complete, navigate to the directory where the tarball was saved and extract its contents. Use the following command to extract the source code:
tar -xf Python-3.13.0.tgz
Step 5: Configure and install Python
Change into the extracted directory and run the configuration script to prepare the source code for installation:
cd Python-3.13.0
./configure –enable-optimizations
Once the configuration is complete, you can compile and install Python by running the following commands:
make -j 4
sudo make altinstall
The -j flag in the make command specifies the number of processor cores to use for compilation. Adjust this number to match the number of cores your system has.
Step 6: Verify the installation
To confirm that Python 3.13 was installed successfully, run the following command:
python3.13 –version
You should see the version number displayed in the terminal, indicating that Python is now installed on your system.
That’s it – you’ve successfully installed Python 3.13 on Ubuntu or another Linux distribution. You can now start using the latest features and enhancements that come with this new release. Happy coding!