Programming

A Guide to Install Flask on Ubuntu 20.04

In this tutorial we will learn how to install Flask on Ubuntu 20.04.

Flask is a micro framework that focuses on the bare minimal. Most basic functionality is integrated in the core. Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy.

Install Flask on Ubuntu 20.04

Prerequisites

Let’s start with the installation process.

1. Keep the server up to date

# apt update -y

# apt upgrade -y

2. Install required package

We need to install python3-venv package to provide the venv module. Run following command to install python3-venv package:

# apt-get install python3-venv -y

3. Create an environment

Create a project directory:

# mkdir myproject
# cd myproject

Now, create a new virtual environment using following command:

# python3 -m venv venv

4. Activate the environment

Before you work on your project, activate the corresponding environment:

# . venv/bin/activate

5. Install Flask

Within the activated environment, use the following command to install Flask:

# pip install Flask

We have successfully installed Flask.

Verify the installation with the following command which will print the Flask version:

(venv)# python -m flask –version

Output:

Python 3.8.5
Flask 1.1.2
Werkzeug 1.0.1

Your Flask version may differ from the version shown here.

In this tutorial we have seen how to install Flask on Ubuntu 20.04.

Related Articles