gpt4 book ai didi

python - 导入 Flask WTF 表单时出现 ImportError

转载 作者:行者123 更新时间:2023-11-28 19:49:13 27 4
gpt4 key购买 nike

我看不出哪里错了。我安装了最新的 WTF 表单,但仍然出现此错误。

方法:

from flask.ext.wtf import Form
from wtforms import PasswordField, validators, fields
from wtforms.fields import TextField, BooleanField
from wtforms.validators import Required, Email, EqualTo

结果:

Traceback (most recent call last):

File "/bin/user_wsgi_wrapper.py", line 67, in __call__
self.error_log_file.logger.exception("Error running WSGI application")
File "/usr/lib/python3.3/logging/__init__.py", line 1269, in exception
self.error(msg, *args, **kwargs)
File "/usr/lib/python3.3/logging/__init__.py", line 1262, in error
self._log(ERROR, msg, args, **kwargs)
File "/usr/lib/python3.3/logging/__init__.py", line 1368, in _log
self.handle(record)
File "/usr/lib/python3.3/logging/__init__.py", line 1377, in handle
if (not self.disabled) and self.filter(record):
File "/usr/lib/python3.3/logflask_wtf
wtformsging/__init__.py", line 687, in filter
for f in self.filters:
File "/bin/user_wsgi_wrapper.py", line 59, in __call__
app_iterator = self.app(environ, start_response)
File "/bin/user_wsgi_wrapper.py", line 73, in import_error_application
raise e
File "/bin/user_wsgi_wrapper.py", line 82, in <module>
application = load_wsgi_application()
File "/bin/user_wsgi_wrapper.py", line 78, in load_wsgi_application
return __import__(os.environ['WSGI_MODULE'], globals(), locals(), ['application']).application
File "/var/www/rcham_pythonanywhere_com_wsgi.py", line 16, in <module>
from addressbook.app import app as application
File "/home/rcham/mysite/addressbook/app.py", line 4, in <module>
from addressbook.forms import LoginForm, ContactsForm
File "/home/rcham/mysite/addressbook/forms.py", line 1, in <module>
from flask.ext.wtf import Form
File "/usr/local/lib/python3.3/dist-packages/flask/exthook.py", line 87, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named flask.ext.wtf
ls /home/rcham/.local/lib/python2.7/site-packages/flask

__init__.py blueprints.py debughelpers.py globals.pyc logging.pyc signals.pyc
views.py __init__.pyc blueprints.pyc debughelpers.pyc helpers.py module.py
templating.py views.pyc _compat.py config.py ext helpers.pyc module.pyc
templating.pyc wrappers.py _compat.pyc config.pyc exthook.py json.py
sessions.py testing.py wrappers.pyc app.py ctx.py exthook.pyc json.pyc
sessions.pyc testing.pyc app.pyc ctx.pyc globals.py logging.py signals.py
testsuite


ls /usr/local/lib/python3.3/dist-packages/ | grep wtf

flask_wtf
wtforms

最佳答案

根据official quickstart , flask.ext.wtf 应该是 flask_wtf.

因此您必须将其导入为:

from flask_wtf import FlaskForm 

至少我有,我是从 pip 安装的。

关于python - 导入 Flask WTF 表单时出现 ImportError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21733201/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com