×

How To Install Python In Ubuntu

How To Install Python In Ubuntu

Ubuntu is free and open-source software and it is an essential part of the Linux distribution.

It is a popular operating system developed by Canonical.

If we start counting the strengths of Python, we can make a long list in which each pointer would speak for itself and that's why Python is unabashedly the most used language by the developers.

Since we all know that python is compatible with all the platforms, let’s understand how does it work on Ubuntu.

So, here we will discuss the steps that we should follow and some pre-requisites that we must have to install Python in Ubuntu.

Let’s quickly understand the steps so here we go-

  1. The first step here is to ensure that the list of packages is updated or not, which can be checked by writing the following command-
sudo apt update
  • Once the packages are updated, the other essential thing is to have an idea about the pre-requisites which can be verified using-
sudo apt install software-properties-common
  • The next step here is to add deadsnakes PPA to our sources list.

Here one question that would strike in the mind of readers that what is 'Deadsnakes PPA'

So the answer for the same is that Deadsnakes PPA(Personal Package Archive) allows us to install multiple versions of Python in Ubuntu.

This particular thing can be implemented using the command-

sudo add-apt-repository ppa:deadsnakes/ppa
  • Once we found out that the repository is enabled now, we can initiate the installation process with the command given below-
sudo apt install python3.8
  • So finally, we have reached the stage where Python has been installed in Ubuntu successfully, if we again want to cross-check or verify its version, this can be done by writing the command given below-
python –version

The second method to install Python in Ubuntu is explained as follows-

Installing from source

  1. The first thing is to update the list of packages and install the ones which are important for building Python source-

sudo apt update

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

  • The next step is to download the latest version of Python from its download page using wget command

wget (Add the address of the latest version, you can obtain it from Python’s download page).

  • When the download process is completed, the next step is to extract the gzipped tarball:
tar -xf Python-3.7.4.tgz
  • The next thing to implement is running the configure script so that it can perform the required number of checks to ensure that all the necessary things on our system is present.
cd Python-3.7.4
./configure –enable-optimizations
  • So now what we have to do is to start the python build process using make:
make -j 8

If you want your build time to be faster, you can adjust the -j flag on the basis of your processor.

The number of cores in the processor can be found by typing nproc.

  • Now we are done with the building process, next, we will install the python binaries with the help of commands written below-

sudo make altinstall

  • Finally, here we have successfully installed Python version 3.7.
  • The installed version can be verified using-

python3.7 –version

  • The output that will be displayed on our screen would be like-

Python 3.7.4

So, hope we all have understood by now that how one language can help us to learn multiple things, It’s features always keep us on the track of enlightenment. We are all set now to work with Python in different operating systems.

We started with some very simple topics and then took a step ahead and stretched our boundaries of learning. We took a deep dive into the various approaches to run a program in Python. Then we looked at the different ways of taking input in Python.

Different IDEs, n number of libraries and tools, and the application and discoveries that we never thought were feasible.

Python has wrapped some interesting features in it and that’s why it is in great demand. So, keep learning and exploring. There are still a lot of things you have to learn.

In our next section, we will learn about the pip command.


Related Topics

Python program to check if two strings are anagram or not

Python program to check if two strings are anagram or not Problem: This is a python program that takes two strings and checks if given strings are anagram or not. Examples: Input: string1...

1 minute read.

Python Lists vs Tuples

The difference between lists and tuples is one of the most frequently asked questions in an interview related to python language. Lists and Tuples are two of Python’s built-in data...

4 minutes read.

Python Goto Statement

We all know that Python is the most basic and widely used programming language in the world. It is also one of the world's most popular and widely used languages....

4 minutes read.

Data Drop in Python

Introduction You'll understand how to delete a group of rows from a Pandas dataframe in this article.You can read this article on How to Drop Columns in Pandas to find out...

6 minutes read.

Python List insert() method

Python List insert() method The list.insert () method in Python inserts an item at the specified position. Syntax list.insert(i, x) Parameter i: This parameter represents a number specifying the position to insert the given value. x: This parameter signifies...

1 minute read.

Math Module in Python

In this article, you are going to learn everything in detail about the “ math “ module in Python. We can normally work with general operations using python without importing or...

16 minutes read.

How to Convert A List into String In Python?

How to Convert A List into String In Python? List is a data structure in Python that can hold values of different data types. The values are enclosed in square brackets...

3 minutes read.

Why learn Python?

All things considered, learning python would be extraordinary, it'll acquaint you with the universe of dynamic programming dialects, if you're somebody who has had a semester of involvement with C. Python...

4 minutes read.

Sublime Python

SUBLIME: A compact, cross-platform code editor called Sublime Text 3 (ST3) is well-known for its quickness, usability, and robust community support. Although it's a fantastic editor out of the box, its...

6 minutes read.

Working with JSON in Python

Python is an Object-Oriented high-level language. Python is designed to be highly beginner-friendly. Python has an English-like syntax, which is very easy to read. In this article, we are going...

4 minutes read.

Python String expandtabs() method

Python String expandtabs() method The string.expandtabs() method in Python returns a copy of the string where all tab characters are expanded using spaces. Syntax String.expandtabs([tabsize]) Parameter tabsize: This parameter specifies the number of characters to...

1 minute read.

Python: SetBitmap() function in wxPython

SetBitmap() function In the last tutorial, we have discussed about the GetLabelText() function of wx.MenuItem class which is one of the important function of this class. Now, in this tutorial, we...

6 minutes read.

Creating new Database using Python MySQL

In this article, we are going to discuss how to create a new database by connecting Python and MySQL. What is a Database? The places or memory used to secure highly and...

6 minutes read.

EDA in Python

The EDA is the exploratory data analysis; the data scientists mainly use the EDA to understand the main features of the data quickly, the variables in python and the relationship...

6 minutes read.

Python RegEx

Python RegEx (python regular expressions) is a concept of writing and finding expressions in a pool of characters easily. A Regular expression (RegEx) is a set of characters that defines search...

10 minutes read.

How to Configure Python Interpreter in Eclipse

Python: Python is an interactive and more accessible language than any other programming language. The python programming language uses a variety of libraries to perform the operations in a faster way....

3 minutes read.

Python Kwargs Example

In this article, we'll talk about Python's kwargs notion. In Python, kwargs has two stars and passes a variable number of keyworded argument lists to the function, whereas args has...

5 minutes read.

How to Concatenate Two Strings in Python

How to Concatenate Two Strings in Python Like the other data types, operations on strings are quite useful when we deal with some real-life applications. Here we will talk about a simple...

4 minutes read.

Python Sending Email

Python Sending Email Simple Mail Transfer Protocol (SMTP) is used to handle sending e-mail and routing e-mail between mail servers. When we send an email either form a web-application or from a local software...

3 minutes read.

Python lock

Before understanding the concept of Python-lock we need to understand what kind if condition we require to implement the locks in Python. Let us start with multithreading and its implementation...

5 minutes read.