Reputation: 59
Am new in flask , but am getting this error , i tired searching on different questions on stackoverflow but i have found none which work, below is the error am getting:
Traceback (most recent call last):
File "C:/Users/Huzy_Kamz/PycharmProjects/articles/articles.py", line 6, in <module>
from wtforms import Form,StringField,TextAreaField,PasswordField, validators
ModuleNotFoundError: No module named 'wtforms'
Then the area which the error is expected is in below the code:
from flask import Flask, render_template, request,flash,redirect,url_for,session,logging,jsonify
#from data import Articles
from flask_mysqldb import MySQL
from _mysql_exceptions import MySQLError
from wtforms import Form,StringField,TextAreaField,PasswordField, validators
from passlib.hash import sha256_crypt
from _mysql_exceptions import IntegrityError
from functools import wraps
Upvotes: 0
Views: 9479
Reputation: 237
I have same problem when I installed a new server with virtualenv.
This is the output when I installed Flask:
$ pip install flask
Collecting flask
Downloading
....
Building wheels for collected packages: itsdangerous, MarkupSafe
Running setup.py bdist_wheel for itsdangerous ... done
....
Successfully built itsdangerous MarkupSafe
Installing collected packages: click, Werkzeug, itsdangerous, MarkupSafe, Jinja2, flask
Successfully installed Jinja2-2.10 MarkupSafe-1.0 Werkzeug-0.14.1 click-6.7 flask-1.0.2 itsdangerous-0.24
I tried to run minimal script:
$ python app.py
Traceback (most recent call last):
File "app.py", line 2, in <module>
from wtforms import Form, BooleanField, StringField, PasswordField, validators
ImportError: No module named wtforms
What I understand is WTFORMS is not installed. I've search in another post and this works for me (How can I import Flask-WTF?):
$ pip install flask-wtf
Collecting flask-wtf
Downloading
....
Collecting WTForms (from flask-wtf)
Downloading
....
100% |████████████████████████████████| 174kB 345kB/s
Requirement already satisfied: Flask in ./lib/python2.7/site-packages (from flask-wtf) (1.0.2)
Requirement already satisfied: click>=5.1 in ./lib/python2.7/site-packages (from Flask->flask-wtf) (6.7)
Requirement already satisfied: Werkzeug>=0.14 in ./lib/python2.7/site-packages (from Flask->flask-wtf) (0.14.1)
Requirement already satisfied: itsdangerous>=0.24 in ./lib/python2.7/site-packages (from Flask->flask-wtf) (0.24)
Requirement already satisfied: Jinja2>=2.10 in ./lib/python2.7/site-packages (from Flask->flask-wtf) (2.10)
Requirement already satisfied: MarkupSafe>=0.23 in ./lib/python2.7/site-packages (from Jinja2>=2.10->Flask->flask-wtf) (1.0)
Installing collected packages: WTForms, flask-wtf
Successfully installed WTForms-2.2.1 flask-wtf-0.14.2
Upvotes: 1
Reputation: 9833
Change your imports on line 6 to:
from wtforms import Form, BooleanField, StringField, PasswordField, validators
Upvotes: 1