I am using Windows10 Home,I have Python3.9.1 and Visual Studio Code.These are mu code:
JavaScript
x
38
38
1
from flask import Flask,render_template,flash,redirect,url_for,session,logging,request
2
from flask_mysqldb import MySQL
3
from wtforms import Form,StringField,TextAreaField,PasswordField,validators
4
from passlib.hash import sha256_crypt
5
6
class RegisterForm(Form):
7
name = StringField("Name Surname",validators=[validators.Length(min=4,max=25)])
8
username = StringField("User name",validators=[validators.Length(min=5,max=35)])
9
email = StringField("Email Adress",validators=[validators.Email(message = "Please enter a valid email.")])
10
password = PasswordField("Password:",validators=[
11
validators.DataRequired(message = "Please enter a password"),
12
validators.EqualTo(fieldname="confirm",message = "Your password is not correct.")
13
])
14
confirm = PasswordField("Verify password")
15
app = Flask(__name__)
16
17
app.config["MYSQL_HOST"] = "localhost"
18
app.config["MYSQL_USER"] = "root"
19
app.config["MYSQL_PASSWORD"] =""
20
app.config["MYSQL_DB"] ="blog"
21
app.config["MYSQL_CURSORCLASS"] = "DictCursor"
22
23
mysql = MySQL(app)
24
25
@app.route("/")
26
def index():
27
return render_template("index.html")
28
29
@app.route("/about")
30
def about():
31
return render_template("about.html")
32
33
if __name__ == "__main__":
34
app.run(debug=True)
35
36
37
38
and I have about.html and index.html file.I know they are correct because I was use they another app.
When I run this code I take this error.I am very new about the software.So I don’t know what should I do
Advertisement
Answer
You need to install all the modules that are used within your project which in your case is flask_mysqldb. Install it with the following cmd:
JavaScript
1
2
1
pip install flask-mysqldb
2