How to install Flask – Python web development micro framework on Ubuntu 18.04 and 19.04
Go ahead and launch your terminal, run the following commands..
sudo apt update && upgrade
I assume that you already have python and pip installed on your Ubuntu Desktop/server. If not, you can install python3 and pip3 with the following commands.
Let’s Install python3 and pip3
sudo apt install python3
sudo apt install python3-pip
Now, let’s check python3 and pip3 version
Install python virtual environment
We’ll create a directory/folder, where python virtual enviroment will be installed and activated.
cd Desktop && mkdir pybox && cd pybox
We just created a directory on the Desktop and changed directory, now, we are in pybox directory.
Let’s install venv and name it venv
python3 -m venv venv
Let’s activate the venv – The Python environment
Make sure you are in pybox direcetory, before start activating python virtual envorinment
Let’s install Flask
pip install flask
Let’s quickly create flask app
Create a folder/directory in the pybox directory/folder
mkdir demoapp && cd demoapp && touch app.py
In app.py file, put the following code
from flask import Flask
app = Flask(__name__)
return "Hello from flask app.py file"
if __name__ == '__main__':
Make sure you are in the flask app root directory and run the following command from the terminal
Now, go ahead and open your preferred browser and navigate to
How to install Flask on Ubuntu 18.04 Video