Python - How to install the Flask framework? - onlinetutorialspoint

PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
JAVAEXCEPTIONSCOLLECTIONSSWINGJDBC
EXCEPTIONS
COLLECTIONS
SWING
JDBC
JAVA 8
SPRING
SPRING BOOT
HIBERNATE
PYTHON
PHP
JQUERY
PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
Flask is a micro web framework written in Python that widely used.  Here the Micro doesn’t mean that your entire web application fits into a single python file, nor it’s lacking in functionality compared to other web frameworks.
The intention of saying the micro framework is, it aims the core platform as simple and extendable. It doesn’t come with any heavy inbuilt package abstractions such as database layers and templating frameworks etc. It lets you decide the things you want to use and it supports extensions to add such dependencies into your application.
It’s always highly recommended to install Flask on the latest Python at least 3.6 and newer.
Installing Python is different for different operating systems, I have written a separate article for windows installation.
On Mac OS you can use the brew command.
% brew install python3
The above command installs the python3 latest version.
$ sudo apt-get install python3 python-env
The above Linux command will install the python3 and python virtual environment.
After you install the Python, let’s install the Flask in your application. Its always recommended to create a python virtual environment whenever we start a new project.
% mkdir flask-hello-world   # create application root folder
% cd flask-hello-world      # get into application folder
% python3 -m venv venv      # create virtual environment(venv)
The above command python -m venv venv creates the virtual environment with venv name. It’s up to you to decide the name of the virtual environment.
% source venv/bin/activate     # Mac/Linux users

> venv\Scripts\activate        # Windows users
Soon after activating the virtual environment, you would have noticed that your prompt is being modified with your virtual environment name like below.
(venv) flask-hello-world %
Now we are all set to install the Flask web framework.
Flask can be installed by using python package installer that is pip
(venv) flask-hello-world % pip install flask
Collecting flask
  Using cached Flask-2.0.1-py3-none-any.whl (94 kB)
Requirement already satisfied: Jinja2>=3.0 in ./venv/lib/python3.8/site-packages (from flask) (3.0.1)
Requirement already satisfied: itsdangerous>=2.0 in ./venv/lib/python3.8/site-packages (from flask) (2.0.1)
Requirement already satisfied: Werkzeug>=2.0 in ./venv/lib/python3.8/site-packages (from flask) (2.0.1)
Requirement already satisfied: click>=7.1.2 in ./venv/lib/python3.8/site-packages (from flask) (8.0.1)
Requirement already satisfied: MarkupSafe>=2.0 in ./venv/lib/python3.8/site-packages (from Jinja2>=3.0->flask) (2.0.1)
Installing collected packages: flask
Successfully installed flask-2.0.1
The above pip install flask command is going to bring Flask from the python package repository along with the number of other packages that Flask depends on.
Werkzeug – implements WSGI framework
Jinja – A templating language that used to render the web pages on the server
MarkupSafe – Cones along with jinja
ItsDangerous – For security integrity
Click – For writing command-line applications
You can verify the Flask installation by importing the flask into the python interpreter like below.
(venv) flask-hello-world % python
Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import flask
>>>
The import flask will bring the flask packages into the python session, if you did not get any errors while importing the flask that means it successfully installed 🙂
More on Flask dependencies
Python Installation
Python Virtual environment
Happy Learning 🙂

How to setup Python VirtualEnv
Python Django Helloworld Example
How to upgrade Python PIP version on Windows
How install Python on Windows 10
Python Selenium HelloWorld Example
Python – How to read environment variables ?
Where can I find Python PIP in windows ?
Python – AWS SAM Lambda Example
Python – Selenium Download a File in Headless Mode
Python Operators Example
Python Selenium Automate the Login Form
Python MySQL create database and table
How to install Maven on Ubuntu 14.x
How to Remove Spaces from String in Python
How to connect MySQL DB with Python

How to setup Python VirtualEnv
Python Django Helloworld Example
How to upgrade Python PIP version on Windows
How install Python on Windows 10
Python Selenium HelloWorld Example
Python – How to read environment variables ?
Where can I find Python PIP in windows ?
Python – AWS SAM Lambda Example
Python – Selenium Download a File in Headless Mode
Python Operators Example
Python Selenium Automate the Login Form
Python MySQL create database and table
How to install Maven on Ubuntu 14.x
How to Remove Spaces from String in Python
How to connect MySQL DB with Python