close

[Solved] Import: No module named MySQLdb

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Import: 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 Import: No module named MySQLdb Error Occurs?

Today I get the following error Import: No module named MySQLdb in python.

How To Solve Import: No module named MySQLdb Error ?

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

    To Solve Import: No module named MySQLdb Error Simply pip install pymysql and switch your SQLAlchemy URI to start like this:

  2. Import: No module named MySQLdb

    To Solve Import: No module named MySQLdb Error Simply pip install pymysql and switch your SQLAlchemy URI to start like this:

Solution 1

If you’re having issues compiling the binary extension, or on a platform where you cant, you can try using the pure python PyMySQL bindings.

Simply pip install pymysql and switch your SQLAlchemy URI to start like this:

SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://.....'

There are some other drivers you could also try.

Solution 2

Or try this:

apt-get install python-mysqldb

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