No module named flask.ext.wtf.SelectField

2019-07-22 05:25发布

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条回答
SAY GOODBYE
2楼-- · 2019-07-22 06:10

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
查看更多
登录 后发表回答