Import "wtforms.fields.html5" could not be resolved

2021. 11. 16. 16:08Trouble shooting/backend

Import "wtforms.fields.html5" could not be resolved

 

from flask_wtf import FlaskForm
from wtforms import StringField, TextAreaField, PasswordField
from wtforms.fields.html5 import EmailField
from wtforms.validators import DataRequired, Length, EqualTo, Email


class QuestionForm(FlaskForm):
    subject = StringField('제목', validators=[DataRequired('제목은 필수입력 항목입니다.')])
    content = TextAreaField('내용', validators=[DataRequired('내용은 필수입력 항목입니다.')])

(...)

여기서 계속 

Import "wtforms.fields.html5" could not be resolved 오류가 떠서

 

pip install email_validator

를 하였으나 그대로 문제가 있어 고민하던 중

 

https://stackoverflow.com/questions/61356834/wtforms-install-email-validator-for-email-validation-support

 

WTForms: Install 'email_validator' for email validation support

Getting exception when running the following code for form validation. File "/Users/homeduvvuri/Documents/Learning/PartyGoUdemy/PartGo/user/forms.py", line 11, in BaseUserForm email = EmailFi...

stackoverflow.com

를 참조하여 해결하였음.

 

'''

From WTForms 2.3.0 version, the email validation is handled by an external library called email-validator (PR #429). If you want to enable email validation support, you either need to install WTForms with extra requires email:

$ pip install wtforms[email]

Or you can install email-validator directly:

$ pip install email-validator

Or you can back to the old version of WTForms:

$ pip install wtforms==2.2.1

P.S. If you are using Flask-WTF, except for install email-validator directly, you can also use email extra (if PR #423 got merged) in the next release (> 0.14.3).

answered Nov 29 '20 at 1:43

'''

 

정확히 2.2.1 버전을 요구 하였음 

728x90