ImportError: cannot import name 'TimedJSONWebSignatureSerializer' from 'itsdangerous'
Question:
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?
Answers:
In the latest version of itsdangerous, TimedJSONWebSignatureSerializer is no longer available. Try this instead. It worked for me. from itsdangerous import URLSafeTimedSerializer as Serializer
Itsdangerous is a very common and popular package used for serialization in other packages and apps.
To fix this:
- Upgrade your Flask to the newest version —
pip install flask –upgrade
- Downgrade itsdangerous to version 2.0.1 —
pip install itsdangerous==2.0.1
- 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
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.
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?
In the latest version of itsdangerous, TimedJSONWebSignatureSerializer is no longer available. Try this instead. It worked for me. from itsdangerous import URLSafeTimedSerializer as Serializer
Itsdangerous is a very common and popular package used for serialization in other packages and apps.
To fix this:
- Upgrade your Flask to the newest version —
pip install flask –upgrade
- Downgrade itsdangerous to version 2.0.1 —
pip install itsdangerous==2.0.1
- 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
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.