Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named flask.ext.wtf

I'm following @Miguel flask mega tutorial which is great. In chapter 3 he talks about web forms and flaskWTF extension, installing the extension like this sudo pip install Flask-WTF resulted in

Successfully installed Flask-WTF Flask WTForms Werkzeug Jinja2 itsdangerous markupsafe

but when executing ./run.py i get an error:

No module named flask.ext.wtf`

I've google the error and tried to run it like this: flask/bin/python run.py but got the same error, also tried flask/bin/activate

Update: if you run into the same error this is what solved the issue for me I've installed the following, for sure they are not all needed but since i didn't go one by one to find out which one did the trick i'm listing them all

flask/bin/pip install flask-login
flask/bin/pip install flask-openid
flask/bin/pip install flask-mail
flask/bin/pip install sqlalchemy
flask/bin/pip install flask-sqlalchemy
flask/bin/pip install sqlalchemy-migrate
flask/bin/pip install flask-whooshalchemy==0.55a
flask/bin/pip install flask-wtf
flask/bin/pip install pytz
flask/bin/pip install flask-babel
flask/bin/pip install flup
like image 222
liv a Avatar asked Nov 17 '13 16:11

liv a


2 Answers

The API has changed from:

from flask.ext.wtf import Form

to:

from flask_wtf import Form

See the docs here

like image 149
Pavel Chernikov Avatar answered Nov 09 '22 19:11

Pavel Chernikov


You are probably using the import style from the older versions:

from flask.ext.wtf import Form, TextField, BooleanField
from flask.ext.wtf import Required

The import style changed starting from 0.9.0 version. Be sure to update your imports:

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

You can find the note about this change in the upgrade section of docs:

https://flask-wtf.readthedocs.org/en/latest/upgrade.html#version-0-9-0

like image 14
jbub Avatar answered Nov 09 '22 19:11

jbub