Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Install Flask in Ubuntu 20.04 - DesignLinux

Jan 15 2021
designlinux 0 Comments

Two commonly used open-source Python web frameworks 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.

Meanwhile, 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.

Without much further ado, let’s jump right in and install the flask on Ubuntu 20.04.

Installing Flask in Ubuntu

1. To install flask on Ubuntu 20.04 using apt package manager, here are the steps to follow:

First, ensure that your system is updated as shown.

$ sudo apt update -y

Once the update is complete, head over to the next step.

2. Next, 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 20.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 20.04 run:

$ python3 --version
Check Python Version in Ubuntu
Check Python Version in Ubuntu

Next, install pip3 and other Python tools as shown.

$ sudo apt install build-essential python3-pip libffi-dev python3-dev python3-setuptools libssl-dev
Install Pip in Ubuntu
Install Pip in Ubuntu

3. Thereafter, install a virtual environment that is going to isolate and run flask in a sandboxed environment.

$ sudo apt install python3-venv
Create Python Virtual Environment
Create a Python Virtual Environment

4. Now, create the flask directory and navigate into it.

$ mkdir flask_dir && cd flask_dir

5. Create a virtual environment using Python as follows.

$ python3 -m venv venv

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

$ source venv/bin/activate

Notice how the prompt changes to (venv) to indicate that we are now working inside the virtual environment.

Active Python Virtual Environment
Active Python Virtual Environment

7. 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
Install Flask in Ubuntu
Install Flask in Ubuntu

8. To confirm that flask is installed, run:

$ flask --version
Check Flask Version in Ubuntu
Check Flask Version in Ubuntu

Perfect! Flask is now installed on Ubuntu 20.04. You can now proceed to create and deploy your Python applications using flask.

Related

Tags: Ubuntu Tips

How to Setup CentOS Stream from AWS Marketplace

Prev Post

Python Tuples

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 4
  • 82
  • 605,832

DesignLinux.com © All rights reserved

Go to mobile version