ModuleNotFoundError: No module named ‘flask’ in Python

Python is a trending language used in almost every field, such as AI, Robotics, Data science, Web development, etc. To create web-based sites and applications, Python provides a “flask” tool/package. To access this module in Python, we need to install it before importing it into the program. The “no module named flask” error occurs in Python when we import the stated module without installing it in Python.

This Python blog will give you the reason and the solutions to the “no module named flask” error in Python. The guide content is as follows:

So, let’s get started!

Reason: Python ‘flask’ Module is Not Installed

We encounter the “no module named flask” error when we try to execute the following code:

The above output shows “ModuleNotFoundError” because the “flask” module has been imported into a program without being installed in Python.

Solution (For Windows): Install the Python Flask Module

To fix this “flask” module error, we need to install this module in Python. The “pip” package manager is used to install this module in Python. If you don’t have pip in Python, you can use the given below command or check this guide:

> py -m ensurepip --upgrade

For the installation of the flask module, you can follow the given below steps:

Step 1: Launch CMD

To open Command Prompt, press (Windows Key + R) button on Keyboard and type the “cmd” command in the run dialog box:

Step 2:Install Flask Using pip

After opening the cmd, now you can use the given below piece of code to install the “flask” module using pip:

> pip install Flask

The above snippet shows the installation of “Flask” in the command prompt terminal.

If you encounter a permission error, then you can use the below code for “flask” installation:

> pip install Flask --user

Step 3: Flask Installation Verification

After installing the “Flask” module, we can verify the module installation using the below command:

> pip show Flask

The above snippet shows that “Flask” version “2.2.2” has been successfully installed in Python version “3.11”.

How to Uninstall the Flask Module?

To uninstall the “Flask,” you can use the given below code:

> pip uninstall Flask

The above snippet shows the “uninstallation” success of the “flask” module from Python.

Install Flask Module in Anaconda

To install the “flask” module in Anaconda, you can type the below command in the terminal:

> conda install -c anaconda flask

Install Flask in Jupyter Notebook

To install the “flask” module in Jupyter Notebook you can execute the below piece of code:

> !pip install Flask

Solution (For Linux): Install the Flask Module in Python

To resolve this error in Linux you need to install the flask module in Python. The “pip” command shown below is utilized in the terminal to install the “flask” module. You can follow this guide if you don’t have a “pip” in Python.

$ sudo pip install flask

To install “flask on Ubuntu 22.04”, you can go through this dedicated guide.

Alternative Reason for ‘No module named flask’ Error in Python

The below table shows some other alternative reason which causes the “no module named flask” error in Python:

Installing the “flask” in a different version of Python.Check the Version before installation.
Installing the “flask” module in global scope rather than in your virtual environment.Install the module in your virtual environment
Having the same variable and Python filename as the “flask” module.Rename the Python file or variable

That’s all to fix the ‘flask’ module not found error in Python.


The “ModuleNotFoundError: No module named ‘flask’ in Python” occurs in Python when we try to import the “flask” module without installation. To resolve this error in Python on Windows and Linux, you can execute the “pip” and “apt” commands from the terminal. The instruction for installing, removing, and verifying the “flask” module has been provided in this Python blog.