How to Install Flask in Ubuntu 21.04

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Introduction

Python web frameworks used 2 open-sources , are Django and Flask. Django is a robust Python framework that allows users to rapidly develop and deploy their web applications by providing an MVC framework that aims at simplifying web app development with less code along with reusable components.

Flask is a microframework that is lean and devoid of extra libraries or tools. It is minimalistic as it ships with only the basic tools to help you get off the ground with developing your applications.

let’s jump right in and install the flask on Ubuntu 21.04.

Install Flask in Ubuntu

1.  Ensure that your system is updated as shown.

$ sudo apt update -y

2. you will need to install pip alongside other Python dependencies which will enable you to create a virtual environment. It’s in the virtual environment that we are going to install flask.

In case you are wondering why we are not installing Python first, well, Ubuntu 21.04 already comes pre-packaged with Python 3.8, and so there’s no need to install it.

To confirm the presence of Python on Ubuntu 21.04 run:

$ python3 --version

3. Install pip3 and other Python tools as shown.

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

4. Install a virtual environment that is going to isolate and run flask in a sandboxed environment.

$ sudo apt install python3-venv -y

5. Create the flask directory and navigate into it.

$ mkdir flask 
$ cd flask

6. Create a virtual environment using Python 

$ python3 -m venv venv

7. Then activate it so that you can install the flask.

$ source venv/bin/activate

8. Lastly, install flask web framework using pip, which will install all the components of flask including Jinja2, werkzeug WSG web application library & its modules.

$ pip3 install flask

9. To get that flask version and make sure that it is installed run:

$ flask --version

You can now proceed to create and deploy your Python applications using flask.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
MQ-Jr
MQ-Jr
unixcop Admin

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook