How to Install Python 3.8 on Ubuntu 18.04?

How to Install Python 3.8 on Ubuntu 18.04?

In this tutorial we'll cover two different ways to install Python 3.8 on Ubuntu 18.04. The first option is to install the deb package from the deadsnakes PPA, and the second one is by building from the source code.

Python is one of the most widely used programming languages in the world. With its simple and easy to learn syntax, Python is a popular choice for beginners and experienced developers. Python is quite a versatile programming language. It can be used to build all kinds of applications, from simple scrips to complex machine learning algorithms.

Python 3.8 is the latest major release of the Python language. It includes many new features such as assignment expressions, positional-only parameters, f-strings support, and more.

Python 3.8 is not available in Ubuntu’s default repositories. In this tutorial, we’ll cover two different ways to install Python 3.8 on Ubuntu 18.04. The first option is to install the deb package from the deadsnakes PPA, and the second one is by building from the source code.

The same steps apply for Ubuntu 16.04 and any Ubuntu-based distribution, including Kubuntu, Linux Mint, and Elementary OS.

Installing Python 3.8 on Ubuntu with Apt

Installing Python 3.8 on Ubuntu with apt is a relatively straightforward process and takes only a few minutes:

  1. Run the following commands as root or user with sudo access to update the packages list and install the prerequisites:
```
sudo apt update
sudo apt install software-properties-common
```
  1. Add the deadsnakes PPA to your system’s sources list:
```
sudo add-apt-repository ppa:deadsnakes/ppa
```



When prompted press `Enter` to continue:



```
Press [ENTER] to continue or Ctrl-c to cancel adding it.
```
  1. Once the repository is enabled, install Python 3.8 with:
```
sudo apt install python3.8
```
  1. Verify that the installation was successful by typing:
```
python3.8 --version
```



```
Python 3.8.0
```

At this point, Python 3.8 is installed on your Ubuntu system, and you can start using it.

Installing Python 3.8 on Ubuntu from Source

In this section, we’ll explain how to compile Python 3.8 from the source.

  1. Update the packages list and install the packages necessary to build Python:
```
sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
```
  1. Download the latest release’s source code from the Python download page using wget:
```
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
```

At the time of writing this article, the latest release is 3.8.0.

  1. When the download finishes, extract the gzipped archive:
```
tar -xf Python-3.8.0.tgz
```
  1. Switch to the Python source directory and execute the configure script which performs a number of checks to make sure all of the dependencies on your system are present:
```
cd Python-3.8.0
./configure --enable-optimizations
```

The --enable-optimizations option optimizes the Python binary by running multiple tests. This makes the build process slower.

  1. Start the Python 3.8 build process:
```
make -j 8
```

For faster build time, modify the -j to correspond to the number of cores in your processor. You can find the number by typing nproc.

  1. When the build process is complete, install the Python binaries by typing:
```
sudo make altinstall
```

Do not use the standard make install as it will overwrite the default system python3 binary.

  1. That’s it. Python 3.8 has been installed and ready to be used. Verify it by typing:
```
python3.8 --version
```



The output should show the Python version:


```
Python 3.8.0
```

Conclusion

You have installed Python 3.8 on your Ubuntu 18.04 machine, and you can start developing your Python 3 project.

If you have any questions or feedback, feel free to comment below.

python Ubuntu

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Basic Data Types in Python | Python Web Development For Beginners

In the programming world, Data types play an important role. Each Variable is stored in different data types and responsible for various functions. Python had two different objects, and They are mutable and immutable objects.

How To Compare Tesla and Ford Company By Using Magic Methods in Python

Magic Methods are the special methods which gives us the ability to access built in syntactical features such as ‘<’, ‘>’, ‘==’, ‘+’ etc.. You must have worked with such methods without knowing them to be as magic methods. Magic methods can be identified with their names which start with __ and ends with __ like __init__, __call__, __str__ etc. These methods are also called Dunder Methods, because of their name starting and ending with Double Underscore (Dunder).

How to Install Pyenv on Ubuntu 18.04

How to Install Pyenv on Ubuntu 18.04 - What is Pyenv? Pyenv is a fantastic tool for installing and managing multiple Python versions. It enables a developer to quickly gain access to newer

How to Install Microsoft Teams on Ubuntu 20.04

In this tutorial, we will show you how to install Microsoft Teams on Ubuntu 20.04 machine. we can install teams using Debian installer file or by adding microsoft repository.

Python Programming: A Beginner’s Guide

Python is an interpreted, high-level, powerful general-purpose programming language. You may ask, Python’s a snake right? and Why is this programming language named after it?