Flask Installation on Ubuntu 20.04

Posted by

We are going to learn flask installation on an Ubuntu system/machine. Flask is an open-source Python micro-framework for making APIs and Web applications.

Here are the steps for installing flask:

1. Check the python version on your system

First, use the below command to check the python version for installing Flask.

It will return the installed version of Python.

Example output
Python 3.9.10

2. Package installation for Virtua Environment

Now, we have to create a virtual environment using a python3-venv package. Run the below command for installing the package.

3. Create a new directory for your application

Create the new project Flask directory and go to it now.

4. Create a Virtual environment

Go to the created directory and run the below command for creating a virtual environment.

5. Activate the environment using the below command

6. Install Python package manager pip to install Flask

Now the virtual environment has been activated. Install the pip(Package Installer for Python) to install Flask.

7. Flask Installation using PIP

Now PIP has been installed. Install the Flask using the below command.

8. Check the Flask version

Flask has been successfully installed. Use the following command to validate the installation. It will show Python and Flask versions.

9. Add Code to your App folder

Now create a file(index.py) in your application folder and add the below code:

10. Set your file in the environment variable

Set the created file(index.py) in the environment.

11. Run the Flask application

After running the command output will be shown below:

* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Flask has been installed on your ubuntu system. You can develop your python application using Flask.

Leave a Reply

Your email address will not be published. Required fields are marked *