'AppEngine Python 502 Bad Gateway - ImportError: cannot import name 'json' from 'itsdangerous'

Last Friday I uploaded a new version of my application to App Engine. It was working before, but now I get a 502 Bad Gateway. If I go into the AppEngine console and direct traffic to an older version it works fine. So, I must have changed something, but what?

I pulled the logs and the following caught my attention:

"/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/json/init.py", line 15, in from itsdangerous import json as _json ImportError: cannot import name 'json' from 'itsdangerous' (/layers/google.python.pip/pip/lib/python3.9/site-packages/itsdangerous/init.py)

My requirements file is here:

Flask==1.1.4
google-cloud-datastore==1.12.0
requests==2.24.0

And my import sections are like this:

from flask import Blueprint, render_template
from flask import session, redirect, url_for, escape, request
from google.cloud import datastore

Any ideas where I can look?



Solution 1:[1]

As indicated in the comment above, the issue was resolved by upgrading from Flask 1.1.2 to Flask 2.0.3

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kxtronic