Forums

Does Flask come with WTForms already installed? ... ImportError: No module named flask.ext.wtf

Alas this noob has no way of knowing if there are any extensions or things or whatever already part of flask framework. Does Flask already come with WTForms installed?

If it does, I get an error ...

ImportError: No module named flask.ext.wtf

Any help? Many thanks

We do have wtform installed for python2.7 and 3.4

However, note that while you do

import flask.ext.wtf

for python2.7, for python3.4, the import statement is something like

from flask_wtf import Form

So check your version vs your import statement. Also, if you are in a virtualenv then you won't have access to the external packages unless you passed a --system-site-packages flag when building it.

no, cant get it too work, now says, from flask_wtf import Form 2015-04-21 12:52:55,532 :ImportError: No module named 'flask_wtf' Tried using various number of import statements, no luck.

I'm NOT using devenv, so can only imagine there is another bug somewhere.

It looks like we don't have Flask-WTF installed for Python 3.4. You can install it for yourself with pip3.4 install --user Flask-WTF

Ok, thanks - or maybe I'll just use python 2.7 ?

That would work too :-)

Hi, I've just started to create a web app within the pythonanywhere environment.

From the start, I wanted to use Python 2.7 for running my web app, and I did select 2.7 accordingly in the web app settings.

Still, when I run the main program (flask_app.py), it's Python 3.4 which is actually used instead of Python 2.7 since I get the error related to the Flask-WTF which is not installed for Python 3.4 indeed :

Traceback (most recent call last): File "/home/pwa/mysite/forms.py", line 9, in <module> from flask.ext.wtf import Form File "/usr/local/lib/python3.4/dist-packages/flask/exthook.py", line 87, in load_module raise ImportError('No module named %s' % fullname) ImportError: No module named flask.ext.wtf

With Python 2.7, I don't expect to get the same kind of error since the import of flask.ext.wtf occurs without any particular problem in a Python 2.7 console:

Python 2.7.6 (default, Mar 22 2014, 22:59:56) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information.

import flask.ext.wtf from flask.ext.wtf import Form

How come it's not Python 2.7 that is not running according to the selection I made in the web app settings in the first place?

In other words, how can I force the use of Python 2.7?

Thank you in advance for your help.

pwa

By the way, when using a virtualenv with Flask-WTF in it, I also have to install again (with pip) all the other packages necessary for running my web app such as numpy, pandas or matplotlip, which is really a shame because all these packages seem to be already installed together with your own versions of python 2.7 or python 3.4. So the actual extension really missing is Flask-WTF for python 3.4, assuming python 3.4 is the default version of python to get a web app up and running on pythonanywhere..

That's a fair point. We'll look at bringing parity between packages available for the different versions of Python.