Flask App shows ImportError: cannot import name 'Markup' from 'jinja2' | After deploying

Fatimah Alqadheeb 1 Reputation point
2022-08-10T16:01:38.653+00:00

Hello,

I have successfully deployed a flask web app on Azure using the GitHub repository with App Service Plan (B2: 3). When I click on the browse button it shows an Application Error page. On the diagnostic page, it shows a Container Crash error: Application Errors that may have caused the container to crash were detected.

And the App logs listed this error ImportError: cannot import name 'Markup' from 'jinja2'

My flask app used the PostgreSQL database, I have followed this tutorial Deploy a Python Django or Flask web app with PostgreSQL - Azure App Service | Microsoft Learn.

Anyone has suggestions I am struggling with this for two weeks!

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,956 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Xiaoou Li 6 Reputation points
    2022-08-15T13:50:32.49+00:00

    I fixed the error by adding jinja2==3.0.3 and werkzeug==2.0.3 in the requirements.txt. I used Flask old version. Its dependencies were broken. You can check container log for the error details.