Determine server OS. We will install to CentOS instead of Ubuntu (Debian) based systems.
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 .
Updating System Packages
It is always recommended that you update the system to the latest packages before beginning any major installations. This is done with the command below:
sudo yum update
Step 1: Install Python 3 and venv
Install Python 3.6 from the Software Collections (SCL) repositories as the default version of Python on CentOS 7 is Python 2.7.5. SCL allows you to install newer versions of python 3.x alongside the default python v2.7.5. To enable SCL, install the CentOS SCL release file which is included in the CentOS extras repository by issuing the command below:
sudo yum install centos-release-scl
Once the repository is enabled install Python 3.6 with the command below:
sudo yum install rh-python36
Step 2: Creating a Virtual Environment
Start by navigating to the directory where you would like to store your Python 3 virtual environments. It can be your home directory or any other directory where your user has read and write permissions.
To access Python 3.6 you need to launch a new shell instance using the scl tool:
scl enable rh-python36 bash
Create a new directory for your Flask application and navigate into it:
Issue the command below to create a new virtual environment:
python3 -m venv venv
venv created will contain a copy of the Python binary, the Pip package manager, the standard Python library and other supporting files.
Next, activate the virtual environment using the activate script by issuing the command below:
Step 3: Install Flask
After activating the virtual environment, use the Python package manager pip to install Flask by issuing the command below:
pip install Flask
Note: Installed successfully. However message appears that ver 9.0.1 installed but 9.2.2 available. May upgrade, via the ‘pip install –upgrade pip’ command.
As advised above:
pip install --upgrade pip python -m flask --version