greyli / helloflask

Hello, Flask!
https://docs.helloflask.com
MIT License
1.85k stars 2.52k forks source link

Exception: Install 'email_validator' for email validation support. #217

Closed suchocolate closed 3 years ago

suchocolate commented 3 years ago

请确保提供下面的信息:

Exception: Install 'email_validator' for email validation support. Traceback (most recent call last)

File "/root/helloflask-master/demos/form/app.py", line 17, in <module>

from forms import LoginForm, FortyTwoForm, NewPostForm, UploadForm, MultiUploadForm, SigninForm, \

File "/root/helloflask-master/demos/form/forms.py", line 60, in <module>

class RegisterForm(FlaskForm):

File "/root/helloflask-master/demos/form/forms.py", line 62, in RegisterForm

email = StringField('Email', validators=[DataRequired(), Email(), Length(1, 254)])

File "/usr/local/lib/python2.7/dist-packages/wtforms/validators.py", line 332, in __init__

raise Exception("Install 'email_validator' for email validation support.")

Exception: Install 'email_validator' for email validation support.

The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.

To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

dump() shows all variables in the frame
dump(obj) dumps all that's known about the object

Brought to you by DON'T PANIC, your friendly Werkzeug powered traceback interpreter. `

greyli commented 3 years ago

可以列一下依赖看看有没有 email-validator:

$ pip list

或是:

$ pip show email-validator

如果创建了虚拟环境,确保激活以后再安装:

$ pip install email-validator
suchocolate commented 3 years ago

感谢回复 上次安装完email-validator之后,flask已经跑起来了,访问 http://192.168.70.138:5000/html报错如下(192.168.70.138是我的Ubuntu1404虚机的IP): `AttributeError

AttributeError: 'module' object has no attribute 'IntFlag' Traceback (most recent call last)

File "/root/helloflask-master/demos/form/app.py", line 12, in <module>

from flask_ckeditor import CKEditor, upload_success, upload_fail

File "/usr/local/lib/python3.4/dist-packages/flask_ckeditor/__init__.py", line 14, in <module>

from flask_ckeditor.fields import CKEditorField  # noqa

File "/usr/local/lib/python3.4/dist-packages/flask_ckeditor/fields.py", line 11, in <module>

from wtforms import TextAreaField

File "/usr/local/lib/python3.4/dist-packages/wtforms/__init__.py", line 11, in <module>

from wtforms import validators, widgets

File "/usr/local/lib/python3.4/dist-packages/wtforms/validators.py", line 9, in <module>

import email_validator

File "/usr/local/lib/python3.4/dist-packages/email_validator/__init__.py", line 6, in <module>

import dns.resolver

File "/usr/local/lib/python3.4/dist-packages/dns/resolver.py", line 32, in <module>

import dns.flags

File "/usr/local/lib/python3.4/dist-packages/dns/flags.py", line 24, in <module>

class Flag(enum.IntFlag):

AttributeError: 'module' object has no attribute 'IntFlag'

The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.

To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

dump() shows all variables in the frame
dump(obj) dumps all that's known about the object`

如果和书相关,给出相关页数/程序/代码片段编号等信息 第4章 表单示例程序 helloflask/demos/form/ 给出使用的操作系统、Python 版本、Flask 版本 Ubuntu1404 Python 3.4.3 Flask 1.1.2

greyli commented 3 years ago

估计是 Python 版本问题,可以升级下试试看。因为和原 issue 无关,可以重开一个 issue,这个先关闭了。