close

[Solved] ModuleNotFoundError: No module named ‘MySQLdb’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error ModuleNotFoundError: No module named ‘MySQLdb’ in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How ModuleNotFoundError: No module named ‘MySQLdb’ Error Occurs?

Today I get the following error ModuleNotFoundError: No module named ‘MySQLdb’ in python.

How To Solve ModuleNotFoundError: No module named ‘MySQLdb’ Error ?

  1. How To Solve ModuleNotFoundError: No module named 'MySQLdb' Error ?

    To Solve ModuleNotFoundError: No module named 'MySQLdb' Error 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!

  2. ModuleNotFoundError: No module named 'MySQLdb'

    To Solve ModuleNotFoundError: No module named 'MySQLdb' Error 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!

Solution 1

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…

Solution 2

You can install mysqlclient with pip

If using Python3, try this:

pip3 install mysqlclient

or in Python2

pip install mysqlclient

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read