skip to Main Content

I’m running a flask app using itsdangerous python package in AWS EC2 instance.

Traceback (most recent call last):
  File "run.py", line 4, in <module>
    app = create_app()
  File "/home/ubuntu/RHS_US/application/portal/__init__.py", line 29, in create_app
    from portal.users.routes import users
  File "/home/ubuntu/RHS_US/application/portal/users/routes.py", line 7, in <module>
    from portal.models import User
  File "/home/ubuntu/RHS_US/application/portal/models.py", line 7, in <module>
    from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
ImportError: cannot import name 'TimedJSONWebSignatureSerializer' from 'itsdangerous' (/home/ubuntu/.local/lib/python3.7/site-packages/itsdangerous/__init__.py)

Any resolution for this?

3

Answers


  1. In the latest version of itsdangerous, TimedJSONWebSignatureSerializer is no longer available. Try this instead. It worked for me. from itsdangerous import URLSafeTimedSerializer as Serializer

    Login or Signup to reply.
  2. Itsdangerous is a very common and popular package used for serialization in other packages and apps.
    To fix this:

    1. Upgrade your Flask to the newest version — pip install flask –upgrade
    2. Downgrade itsdangerous to version 2.0.1 — pip install itsdangerous==2.0.1
    3. After downgrading it, install email_validator again to make the issue fixed — pip install email_validator

    I hope this fixes the issue for you. Happy Coding

    Login or Signup to reply.
  3. First make sure to re-install and update itsdangerous.
    pip install -U itsdangerous

    Then what you want to do is

     from itsdangerous.url_safe import URLSafeTimedSerializer as Serializer
    

    This works well.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search