Search code examples
pythonflaskpackageflask-wtformspython-venv

Importing flask.ext.wtf


I am using venv, and I develop using eclipse . I want to add a contact page .

I did :

$ . bin/activate
$ pip install flask-wtf

And I import some modules in the forms.py :

I used this :

from flask.ext.wtf import Form, TextField, TextAreaField, SubmitField

and then this :

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

No one of them worked because I had this error :

from flask.ext.wtf import Form
  File "/usr/local/lib/python2.7/dist-packages/flask/exthook.py", line 87, in load_module
    raise ImportError('No module named %s' % fullname)
ImportError: No module named flask.ext.wtf

Solution

  • I solved this by using venv/bin/pip install flask-wtf instead of pip install flask-wtf (even if I activated venv before the second command . bin/activate )