Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'json' from 'itsdangerous' (/usr/local/lib/python3.8/dist-packages/itsdangerous/__init__.py) #49

Open
jasonoma-aws opened this issue Feb 18, 2022 · 3 comments

Comments

@jasonoma-aws
Copy link

jasonoma-aws commented Feb 18, 2022

TeamRole:~/environment/amazon-ecs-mythicalmysfits-workshop/workshop-1/app/monolith-service (master) $ docker run -p 8000:80 -e AWS_DEFAULT_REGION=$AWS_REGION -e DDB_TABLE_NAME=$TABLE_NAME monolith-service
Traceback (most recent call last):
  File "mythicalMysfitsService.py", line 3, in <module>
    from flask import Flask, jsonify, json, Response, request
  File "/usr/local/lib/python3.8/dist-packages/flask/__init__.py", line 21, in <module>
    from .app import Flask, Request, Response
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 25, in <module>
    from . import cli, json
  File "/usr/local/lib/python3.8/dist-packages/flask/json/__init__.py", line 21, in <module>
    from itsdangerous import json as _json
ImportError: cannot import name 'json' from 'itsdangerous' (/usr/local/lib/python3.8/dist-packages/itsdangerous/__init__.py)

This is at the end of lab 1

TABLE_NAME=$(aws dynamodb list-tables | jq -r .TableNames[0])
docker run -p 8000:80 -e AWS_DEFAULT_REGION=$AWS_REGION -e DDB_TABLE_NAME=$TABLE_NAME monolith-service

Based on this post issue appears to stem from:
Flask 1.1.2 is set up to require itsdangerous >= 0.24. The latest released (itsdangerous) version (2.10) deprecated the json API. To continue using Flask 1.1.2, you need to require at most itdangerous 2.0.1 (not 2.10)

From that page:
Found the same problem today. I used Flask in version 1.1.2. The problem disappeared after update to version 1.1.4.

And also impacted the AWS SAM CLI:

With the temporary fix being:


Downgrading markupsafe to 2.0.1 fixes the issue on my side.
pip install markupsafe==2.0.1
@jasonoma-aws
Copy link
Author

Updating requirements.txt file to this appears to fix:

Flask==1.1.4
flask-cors==3.0.0
boto3==1.9.22
markupsafe==2.0.1

@EswarKakani
Copy link

Updating Flask==1.1.4 and markupsafe==2.0.1 works for me.

@ArlindNocaj
Copy link

for me fixing one package fixed it

itsdangerous==2.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants