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?

santiagoorpi
  • 119
  • 1
  • 6

4 Answers4

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
davidism
  • 121,510
  • 29
  • 395
  • 339
John McCabe
  • 702
  • 1
  • 6
  • 16
  • 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? – santiagoorpi Feb 18 '22 at 20:55
  • Do you mean that the version of your App Engine service changed? It shouldn't as the runtime is [defined](https://cloud.google.com/appengine/docs/standard/python3/configuring-your-app-with-app-yaml) on `runtime` configuration item from the `app.yaml` file. – Emmanuel Feb 22 '22 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 :( – santiagoorpi Feb 24 '22 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](http://issuetracker.google.com/) – Emmanuel Feb 28 '22 at 14:59
  • Thank you!! I was pulling my hair out about this error! – Jim In Texas Apr 22 '22 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.

  • 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`. – Jose Rondon Feb 21 '22 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.

davidism
  • 121,510
  • 29
  • 395
  • 339
new name
  • 15,861
  • 19
  • 68
  • 114
1

the deprecation is performed with itsdangerous > 2.0.1.

khancell
  • 329
  • 2
  • 4