Install Python3 Ubuntu

Introduction to Python

Python is a general-purpose, high-level, object-oriented, interactive, and interpreted programming language. During 1985-1990, it was developed by Guido van Rossum. Also, the source code of Python is available upon the GNU GPL (General Public License) like Perl. Python language is named after a television show known as eMonty Pythonis Flying Circusi and not after Python snake.

The 3.0 version of Python was published in 2008. However, this version is assumed to be backward incompatible, later several of its essential aspects have been backported to be suitable for the 2.7 version.

Python History

Python was integrated by Guido van Rossum in the early 90s and late 80s at the National Research Institute for Computer Science and Mathematics in the Netherlands.

  • It is acquired from several other languages including Unix shell, SmallTalk, Algol-68, C++, C, Modula-3, ABC, and other scripting languages.
  • It is copyrighted.
  • Now, Python is managed by a core development team in the institute. However,
  • Guido van Rossum holds an important role in directing its aim.
  • The 1.0 version of Python was published in November 1994. The 2.0 version of Python was published in 2000. The 2.7.11 version of Python is the latest version of Python 2.
  • Python 3 isn't backward suitable to Python 2. The priority of Python 3 had been on the evacuation of duplicate programming modules and constructs so that "There should be one and preferably only one obvious way to do it". The 5.1 version of Python is the latest release of Python 3.

Why Learn Python 3?

Python is an object-oriented, interactive, interpreted, and high-level scripting language. It is developed to be highly readable. It frequently applies English keywords in which other languages apply punctuations and it contains fewer syntactical constructions as compared to other languages.

Python language is a must for working professionals and students to become the best software engineer specifically when they want to be in the Web Development Domain. We will list down a few advantages of understanding Python:

Install Python3 Ubuntu
  • Language of beginners- Python is the best language for a beginner-level programmer and supports a huge variety of application development from normal text processing to world wide web browsers to several games.
  • Object-oriented- The language supports object-oriented technique or style of programming that encloses the code in objects.
  • Interactive- We can sit at the Python prompt and directly negotiate with the interpreter for writing our programs.
  • Interpreted- The language is processed during the runtime via an interpreter. We don't require to compile over a program before running it. It is the same as PHP and PERL.

Python Characteristics

Below are some essential Python characteristics:

  • It supports structured and functional programming methods and object-oriented programming.
  • It could be applied as a scripting language or could be compiled to byte code to build large applications.
  • It supports dynamic type checking and offers high-level dynamic data types.
  • It could be easily integrated with Java, CORBA, ActiveX, COM, C++, and C.
  • It supports garbage collection.

Python Applications

As mentioned above, Python is one of the most used languages on the web. We are going to list some of them below:

Install Python3 Ubuntu
  • Easy to learn: Python contains transparently defined syntax, simple structure, and some keywords. It permits the students to quickly pick up the language.
  • Easy-to-read: The code of python is more transparently described and clear to the eyes.
  • Large standard library: The bulk of the library of Python is very convenient and cross-platform compatible on Macintosh, Windows, and UNIX.
  • Easy-to-maintain: The source code of Python is clearly easy to maintain.
  • Interactive mode: Python supports an interactive mode that permits code snippet debugging and interactive testing.
  • Portable: Python can be executed on a huge range of hardware platforms and includes a similar interface on every platform.
  • Databases: Python offers interfaces to every big commercial database.
  • Extendable: We can include low-level modules into the Python interpreter. They enable programmers to customize or add their tools to be more dynamic.
  • Scalable: Python offers a good structure and supports large programs as compared to shell scripting.
  • GUI Programming: Python provides its support for GUI applications that could be established and ported to several libraries, system calls, and Windows systems like Macintosh, Windows MFC, and the UNIX X Windows System.

Improved Modules of Python 3.8

Install Python3 Ubuntu
  • ast
    Now, AST nodes contain end_col_offset and end-lineno attributes which provides the precise location of the completion of the node. It only used on the nodes that have col_offset and lineno attributes.
  • asyncio
    asyncio.run () has been promoted from the temporary to stable API. It could be used for executing a co-routine and returning the output while handling the event loop automatically.
  • builtins
    The built-in compile () has been developed for accepting the flag, i.e., ast.PyCF_ALLOW_TOP_LEVEL_AWAIT. Compile () will permit top-level async, async for, and await constructs that are examined as an invalid syntax with this flag passed.
  • collections
    The method, i.e., _asdict () for collections.namedtuple () returns a dict rather than the collections.OrderedDict. It works due to the regular dicts that have ensured ordering since the 3.7 version of Python. If the other aspects of OrderedDict are needed, the recommended remediation is to cast the output to the desired type.
  • cProfile
    The class, i.e, cProfile.Profile can now be applied as the context manager.
  • csv
    Now, the csv.DictReader returns dict instances rather than collections.OrderedDict. Now, the tool is faster and utilizes less memory while preserving the order of the field.

Installing Python3 in Ubuntu

We will explain the steps for installing Python3 in Ubuntu in this article. Python is a very famous open-source, high-level, and interpreted programming language. Programmers and developers love to code in Python because of its easy development with other programming languages. However, there are several ways for installing Python3 in Ubuntu but here we will concentrate on the easiest way.

Prerequisites

  • We should have an active Ubuntu server.
  • We should have root or sudo access for running privileged commands.
  • We should have apt-get or apt utility installed on our server.

Update our server

It is always recommended to update our system using the apt-get update or apt update command before we think about installing a new package. These commands will install every version of our package and decrease the chances of broken package errors.

The command is as follows:


Install Python3 Ubuntu

Installing Python3.8

While we can install any version of the python3 package based on our requirement but here we will install the current version with the help of the following command:

Or


Install Python3 Ubuntu

Checking Python3.8 version

We can check the installed Python version with the help of the following command:


Install Python3 Ubuntu

Write our first program using Python3.8

We must be now thinking about how we can verify the usability of the Python tool. We can write an easy Python file and execute it to confirm. For example, we are writing an easy Python program for printing 'hello world'. We are making a new file known as 'hello.py' with the help of the nano editor and specifying a print statement to show 'hello world'.

How to uninstall Python3.8

If we want to remove Python from our Ubuntu system which we have installed previously, we can uninstall it by using the following command:

Installing Python3.9

There are two primary approaches for installing Python 3.9 in the Ubuntu system. But we will proceed with the straightforward and convenient approach. Our terminal will be opened by clicking Ctrl+Alt+T. Once our terminal is opened, we can follow the following steps.

Step 1- Adding PPA repository

First of all, we need to add the PPA repository before going to directly install Python 3.9 in the Ubuntu system.

The command is as follows:

Step 2- Update the system

We can apply the update command for updating our apt cache. This command will aid to update every package listed in Ubuntu.

Step 3- Install Python 3.9

Once every package is updated, we can use the following command for installing the updated release of Python 3.9:

Step 4- Checking the version

Python 3.9 is now installed on our system. We can check the version of Python with the help of the following command:

The installation process of the 3.9 version of Python is now completed.

How to Remove Python 3.9 from Ubuntu

In addition, if we wish to uninstall or remove python 3.9, the below command will be applied and it will delete Python 3.9 version from our system:

Note: We can install python3.9 similarly like python3.8.