×

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 String isalpha() method

Python String isalpha() method The string.isalpha () method in Python returns a boolean value true if all characters in the  string are alphabetic else for any other value it returns false. Syntax isalpha()  Parameter NA Return This...

1 minute read.

Python List count() method

Python List count() method The list.count() method returns the number of times x appears in the list. Syntax list.count(x) Parameter x: This parameter represents the value to search for and can contain any iterable (list, set, tuple, etc.) Return This method returns the...

1 minute read.

Closest Pair of Points in Python

We are given an array of n points in the plane, and our task is to find the pair of points in the array that are the closest to each...

3 minutes read.

How to import numy in python

How to Install NumPy in Python Python is a vast ocean of libraries, modules, and different functions. It has a solution for almost everything. Using Python, we can simplify even a...

3 minutes read.

Program of Cumulative Sum in Python

Introduction This tutorial, explains what is meant by lists, the cumulative total, several approaches to calculating the cumulative sum of digits in a list, etc. Learn the straightforward Python codes for...

5 minutes read.

Python Program to Print all the Prime Number in an Interval

Python Program to Print all the Prime Number in an Interval What is Prime numbers? A prime number is referred to those numbers that can be divisible by them only. In simple words,...

4 minutes read.

Python Tutorial

Python tutorial is a widely used programming language which helps beginners and professionals to understand the basics of Python programming easily. Python is a high-level, easy, interpreted, general-purpose, and dynamic programming...

19 minutes read.

Word frequency Python

Word frequency Python In this tutorial, we will write the Python program to count the occurrence of a word (word frequency) in a given sentence. We will learn all the approaches...

5 minutes read.

Convert uppercase to lowercase in Python

Python String lower() By using the built-in string lower() method, all the uppercase characters can be converted into lowercase characters in a string, The lowercased string from the given string is returned...

1 minute 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.

YOLO Python

YOLO means you only look once.It is a technique to perform object detection is called YOLO. It is the algorithmused by the program to identify items in the image. Earlier detection...

4 minutes read.

Python Pass Statement

The pass statement is a null statement. The difference between pass and comment is that comment is ignored by the interpreter, whereas pass is not. The pass statement is typically used...

3 minutes read.

Dictionary to JSON Python

In python JSON (JavascriptObject Notation). In the programming language, the text file is made using the script file.We can use many built-in packages which arenamedJSON.Before using the packages, we have...

3 minutes read.

Python Break Statement

In Python, loops are used to automate and repeat processes in an effective manner. However, there may be occasions when you wish to entirely exit the loop, skip an iteration,...

2 minutes read.

How to get Time in seconds in Python

Python's time module source shows that are based on time. The time() method is used by developers and returns the current time as a UNIX timestamp. A UNIX timestamp is...

4 minutes read.

Convert XML to JSON in Python

XML conversion is very useful if we work on an API that returns data in JSON format and the source of data is in XML format. JSON A JSON file reserves the...

4 minutes read.

Event Key in Python

Python Programming Language: Python programming language is one of the most used programming languages, as it is used widely in the field of software and data analysis, web development, etc. It...

3 minutes read.

How to Install Matplotlib in Python?

How to Install Matplotlib in Python The speed at which the enormous amount of data is generating has become a huge aid in understanding what's going on currently in the market....

4 minutes read.

Insertion Sort using Python

Insertion sort is a type of sorting technique that is used for sorting an array with random elements. Using sorting methods, any unsorted array can be sorted into ascending or...

3 minutes read.

An Introduction to Mocking in Python

Python Mocking is a testing library. It enables you to substitute portions of your system under test with fake(mock) objects and make assertions about how they were utilized.  The test is...

3 minutes read.