Hamsa K
4 min read | 3 years ago

How to Install Flask on Ubuntu 20 04

Install Flask on ubuntu 20.04

Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries. It has no database abstraction layer, form validation, or any other components where pre-existing third-party libraries provide common functions.

In this tutorial, we will show you how to install Flask on Ubuntu 20.04 system.

First we will update system paackages using apt.

sudo apt update

python3 is the default version in ubuntu 20.04 you can check the version with the following command.

python3 --version

sample output:

Python 3.8.2

Also Read -> How to Install Eclipse IDE on Ubuntu 20 04

Now install below packages 

sudo apt install python3-pip python3-dev build-essential libssl-dev libffi-dev python3-setuptools

next, you can install virtual environment using below command.

sudo apt install python3-venv

Once the module is installed, we are ready to create a virtual environment for the Flask application.you can create new directory and switch to that directory

mkdir flaskapp
cd flaskapp

run below command inside the directory to create virtual environment.

python3 -m venv venv

it will create venv directory and contains libraries and supporting files.To start using the virtual environment, you need to activate it.

source venv/bin/activate

now install Flask

pip install Flask

Also Read -> How to Install Apache Kafka on Ubuntu 20 04

sample output:

ubuntu@ubuntu20:~/flask_dir# source venv/bin/activate
(venv) root@ubuntu20:~/flask_dir# pip install Flask
Collecting Flask
  Downloading Flask-1.1.2-py2.py3-none-any.whl (94 kB)
     |████████████████████████████████| 94 kB 134 kB/s
Collecting click>=5.1
  Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
     |████████████████████████████████| 82 kB 142 kB/s
Collecting itsdangerous>=0.24
  Downloading itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
Collecting Jinja2>=2.10.1
  Downloading Jinja2-2.11.3-py2.py3-none-any.whl (125 kB)
     |████████████████████████████████| 125 kB 398 kB/s
Collecting Werkzeug>=0.15
  Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
     |████████████████████████████████| 298 kB 260 kB/s
Collecting MarkupSafe>=0.23
  Downloading MarkupSafe-1.1.1-cp38-cp38-manylinux2010_x86_64.whl (32 kB)
Installing collected packages: click, itsdangerous, MarkupSafe, Jinja2, Werkzeug, Flask
Successfully installed Flask-1.1.2 Jinja2-2.11.3 MarkupSafe-1.1.1 Werkzeug-1.0.1 click-7.1.2 itsdangerous-1.1.0

you can check the flask version using below command.

python -m flask --version

sample output:

(venv) ubuntu@ubuntu20:~/flask_dir# python -m flask --version
Python 3.8.5
Flask 1.1.2
Werkzeug 1.0.1

Now you have successfully installed flask on ubuntu 20.04 system.

Also Read -> How to Install Android Studio on Ubuntu 20 04

Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy