Emil
Emil

Reputation: 63

Flask App with Azure AD Example on Windows 10

I try the example on: https://github.com/Azure-Samples/ms-identity-python-webapp with Windows 10, but I get an error with ModuleNotFoundError: No module named 'flask_caching.backends.filesystem' (Flask-Caching is already installed with pip).

Version: Python 3.9.9, Flask 1.1.4 and Werkzeug 1.0.1.

I only changed the code with Client_ID, CLient_Secret and domain name in app_config.py. Has anybody an idea?

Upvotes: 0

Views: 388

Answers (1)

kavya Saraboju
kavya Saraboju

Reputation: 10831

The error ModuleNotFoundError means python interpreter cannot find the libraries which you are referring to in the code although the module is already installed.

Common causes of this error:

  1. Using modules meant for different python versions but Installing python 2.x modules in python 3.x and vice a versa.
  2. When not properly setting PATH variable.

(Or)

If you are using a python virtual environment. It need to be installed after creating a virtual environment as commented by @grumpyp . The libraries will reside inside the folder created for the virtual environment. And can installed according to requirements.txt file

pip install virtualenv

It requires activation and dedicated installation of modules inside the virtual environment. Refer this blog for more details to do

pip install -r requirements.txt

Other reference :Set Up a Virtual Python Environment (Windows)

(or )

This may not be your query but Just to make it a bit easy You can try this way when trying out your sample project to compare with manually configured one.

The quick start: "Add sign-in with Microsoft to a Python web app" that you are using ,can be directly configured in portal quickstart like below where every thing is configured including client id ,tenant id etc directly.

  1. Just register the app with name and account type and follow the steps below for direct configuration .
  2. Go to quickstart page of app

enter image description here

  1. Select Python as platform for web application

enter image description here

  1. Just follow the steps to configure azure ad inside app directly

enter image description here

There after following the steps , I checked the versions with pip freeze and

versions i have: Python 3.9.7, Flask 1.1.4 and Werkzeug 1.0.1.

quickstart-v2-python-webapp | microsoftdocs

Upvotes: 1

Related Questions