flask-wtf
flask-wtf copied to clipboard
AttributeError: module 'quart.json' has no attribute 'JSONEncoder'
Bump into this error when I run pipenv run hypercorn --reload --quic-bind 0.0.0.0:4433 --certfile server.crt --keyfile server.key --bind 0.0.0.0:8080 src.main:app
:
<snip>
File "/usr/src/PythonRestAPI/src/main.py", line 5, in <module>
from flask_wtf.csrf import CSRFProtect, CSRFError
File "/home/khteh/.local/share/virtualenvs/PythonRestAPI-JI5RzKtM/lib/python3.10/site-packages/flask_wtf/__init__.py", line 4, in <module>
from .recaptcha import Recaptcha
File "/home/khteh/.local/share/virtualenvs/PythonRestAPI-JI5RzKtM/lib/python3.10/site-packages/flask_wtf/recaptcha/__init__.py", line 1, in <module>
from .fields import RecaptchaField
File "/home/khteh/.local/share/virtualenvs/PythonRestAPI-JI5RzKtM/lib/python3.10/site-packages/flask_wtf/recaptcha/fields.py", line 3, in <module>
from . import widgets
File "/home/khteh/.local/share/virtualenvs/PythonRestAPI-JI5RzKtM/lib/python3.10/site-packages/flask_wtf/recaptcha/widgets.py", line 6, in <module>
JSONEncoder = json.JSONEncoder
AttributeError: module 'quart.json' has no attribute 'JSONEncoder'
Environment:
- Python version: 3.10.4
- Flask-WTF version: 1.0.1
- Flask version: 2.1.3 https://github.com/pallets/quart/issues/163
A temporary issue that seems to work for me is to change the import to:
from flask.json.provider import DefaultJSONProvider
and then change the JSONEncoder object to:
JSONEncoder = DefaultJSONProvider
How to use this in our applicaton? The error happens inside the library and my application doesn't reference JSONEncoder
directly.