简体   繁体   中英

Python Flask_MYSQLDB problems

Hi

I have been following a step by step on how to make a login system with python , with flask-mysqldb. I'm trying to run the python script, but i end up getting a error message that i don't understand so much of.

from flask import Flask, render_template, request, redirect, url_for, session
from flask_mysqldb import MySQL
import MySQLdb.cursors
import re

app = flask(__name__)

When I'm trying to run the script, on the localhost page it also shows a error , I have copyed and pasted te error in pastebin. When I try to install the flask_mysqldb i get a error in my cmd. Here is what my cmd says .

I have google with parts of the error, trying to find some information about what the problem can be. And tryed to pip install a lot for things that some people have said that can work, without any luck. And can't figure out how to get this to work.

I also tryed to install Anaconda terminal to run the command in there for installing flask_mysqldb, but no luck. Tryed to uninstall and reinstall everything, but nothing changed the error i get.

The error:

ModuleNotFoundError: No module named 'flask_mysqldb'

indicates that the module has not been installed or installed in a wrong environment. Install it using:

pip install flask-mysqldb

The stack from from the error

  File "c:\users\chris\appdata\local\programs\python\python37-32\lib\site-packages\flask\cli.py", line 240, in locate_app
    __import__(module_name)
  File "C:\xampp\htdocs\pythonlogin\main.py", line 2, in <module>
    from flask_mysqldb import MySQL
ModuleNotFoundError: No module named 'flask_mysqldb'

is indicating that Python 3.7 in involved.

In this case, using pip to install flask_mysqldb will lead to grief. Use pip3 instead. Eg,

pip3 install flask_mysqldb

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM