How to Install Flask on Ubuntu 20.04

The Flask is a free Python-written micro web-based framework. We have used the termed microframework because you don’t need additional libraries and tools to work with it.

It is quite simple for beginners to build maintainable, scalable, and secure web applications using the Flask. Unlike Django (another python framework), a user doesn’t need ORM and other functionality from the third-party libraries.

The advantage of using the Flask is, it has built-in python packages to give additional functionalities to the flask application.

How to Install Flask on Ubuntu 20.04

To get Flask application, follow the listed steps:t

Using the apt package manager, the installation process of a Flask on Ubuntu 20.04 is pretty straightforward. What you need to do first is update all the packages of the Ubuntu system through the command:

$ sudo apt update

We don’t need to install python on the system as it is a built-in package on the Ubuntu machine. To ensure its presence, run the mentioned command in the terminal:

$ python3 --version

Move to the next command to create a virtual environment of python through the python3-venv package as given:

$ sudo apt install python3-venv

Make a new directory for the Flask application and using the below-mentioned command to navigate it:

$ mkdir flask_dir && cd flask_dir

Once you created the directory, head over and run the next command to create a virtual environment inside the “flask_dir” directory:

$ python3 -m venv venv

The “venv” is the name of the virtual environment directory. To install the Flask, we need to activate this directory:

$ source venv/bin/activate

After the complete setup of installing python and creating directories, now you can install the Flask framework with all of its components through the Python package manager “pip”:

$ pip install flask

To verify, execute the given command:

$ python -m flask --version

How to create a Flask application

Let’s create a simple Flask application to show how it works:

In the “flask directory (we created above), write a simple program in a text editor and save it with the “.py” extension.

For example, in my system, I created a file named “” in the “flask_dir” directory and write a small program in it:

Now, open the terminal and run the following commands to run the flask application on the server:

Open the server link, and you will get the result:


The Flask is a python written web framework designed to build web applications. The guide has shown how to install the Flask framework and its usage. We created the virtual environment first and installed the Flask framework, then wrote an example code to check how the Flask application works. Unlike Django, you don’t need any specific tool or libraries to work with flask.

About the author

Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.