No module named flask.ext.wtf.SelectField

╄→гoц情女王★ 提交于 2019-12-11 03:54:06

问题


I found flask-jquery-ajax-example and I tried to run it with the latest library versions:

$ pip install flask flask-wtf wtforms
$ pip install -e ./

However, I got the ImportError: No module named flask.ext.wtf.SelectField while starting the scripts:

$ python bin/runserver.py
Traceback (most recent call last):
  File "bin/runserver.py", line 2, in <module>                                                                                                                                                                                                                                
from fjae import run_dev_server                                                                                                                                                                                                                                           
  File "/home/mic/tmp/flask-jquery-ajax-example/fjae/__init__.py", line 3, in <module>                                                                                                                                                                                   
from fjae import views                                                                                                                                                                                                                                                    
  File "/home/mic/tmp/flask-jquery-ajax-example/fjae/views.py", line 6, in <module>                                                                                                                                                                                      
from fjae.forms import VehicleForm                                                                                                                                                                                                                                        
  File "/home/mic/tmp/flask-jquery-ajax-example/fjae/forms.py", line 1, in <module>                                                                                                                                                                                      
from flask.ext.wtf import Form, SelectField                                                                                                                                                                                                                               
  File "/home/mic/.virtualenvs/unisnp/lib/python2.7/site-packages/flask/exthook.py", line 87, in load_module                                                                                                                                                             
raise ImportError('No module named %s' % fullname)                                                                                                                                                                                                                        
ImportError: No module named flask.ext.wtf.SelectField

Did SelectField is replace by a new method?


回答1:


That tutorial hasn't been updated in about 2 years. Flask-WTF dropped support for field imports several versions ago. You need to import them directly from WTForms.

from wtforms import SelectField


来源:https://stackoverflow.com/questions/26159278/no-module-named-flask-ext-wtf-selectfield

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!