9

I have a flask app running in Google App Engine. Yesterday, I deployed a new version of my app where I only change the HTML style. It deployed as it was supposed to. Today, I realized that I didn't change the title for each corresponding HTML page, so I only changed the title tag in each HTML page. I deployed the app again and now I'm getting this strange error of an Import Error for a module that I have never even used. How can I fix this?

The error:

ImportError: cannot import name 'json' from 'itsdangerous' (/layers/google.python.pip/pip/lib/python3.7/site-packages/itsdangerous/__init__.py)

EDIT FEB 24, 2022:

enter image description here

as you can see, the original folder to python3.7 has been replaced with python3.9

Is this normal in GAE?

4 Answers 4

6

This issue on Flask's GitHub is related.

Either update to Flask>2, or if that's not possible pin ItsDangerous<2 and MarkupSafe<2.

To pin to lower versions in a requirements.txt file:

flask==1.1.4
itsdangerous==1.1.0
markupsafe==1.1.1
5
  • thank you! What had happend also was the that in the traceback, the directory says python3.7 which is the version I have always used. When I search the folder for python 3.7, Google App Engine last night had replaced it with python3.9....do you know if this always happens like this without warning? Commented Feb 18, 2022 at 20:55
  • Do you mean that the version of your App Engine service changed? It shouldn't as the runtime is defined on runtime configuration item from the app.yaml file.
    – Emmanuel
    Commented Feb 22, 2022 at 14:58
  • yes sir it did....the app.yaml had not changed from its original 3.7 as i had left it.....but python version 3.7 was no longer in my cloud shell....there is only 2 folders...one that says Python2.7 and Python3.9....really weird :( Commented Feb 24, 2022 at 20:42
  • if this happens again I suggest to write the details it on another post on Stack or even report it on Googles issue tracker
    – Emmanuel
    Commented Feb 28, 2022 at 14:59
  • Thank you!! I was pulling my hair out about this error! Commented Apr 22, 2022 at 21:59
4

I had the same issue today. I was using flask=1.1.2, and when I updated the version to flask==2.0.3, the import issue was resolved.

1
  • I tried this and in fact worked for fixing the issue originally stated. But later in my code I had an operation with .__dict__ property. Broke there because keys are not the same as in 1.1.2. For making things work without changing my code for the moment, stick to keep using flask=1.1.2 and added these to requirements.txt: itsdangerous==1.1.0 markupsafe==1.1.1. Commented Feb 21, 2022 at 10:42
3

This is caused by changes in Flask dependencies. Another question about this was asked on ServerFault.

You can either upgrade to Flask>2, or I had to downgrade to itsdangerous==2.0.1 if you can't do that.

0
1

the deprecation is performed with itsdangerous > 2.0.1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.