ModuleNotFoundError: No module named 'MySQLdb' ModuleNotFoundError: No module named 'MySQLdb' flask flask

ModuleNotFoundError: No module named 'MySQLdb'


I have read that mysqldb is not supported by python3

And it looks like when you are trying to connect to your database you are using mysql db to connect to the database by default!

you need to change it by editing your DATABASE_URI configuration

But before you need to install the connector extension :

with this command :

pip install mysql-connector-python

And according to this documentation you can edit your DATABASE_URI and change the default connector like this :

DATABSE_URI='mysql+mysqlconnector://{user}:{password}@{server}/{database}'.format(user='your_user', password='password', server='localhost', database='dname')

I hope this will help...


You can install mysqlclient with pip

If using Python3, try this:

pip3 install mysqlclient

or in Python2

pip install mysqlclient


To install MySQLdb, provided pip or pip3 is installed on your machine:

pip install mysqlclient