Categories
Python Answers

How to fix ImportError: No module named MySQLdb with Python Flask?

Spread the love

Sometimes, we want to fix ImportError: No module named MySQLdb with Python Flask.

In this article, we’ll look at how to fix ImportError: No module named MySQLdb with Python Flask.

How to fix ImportError: No module named MySQLdb with Python Flask?

To fix ImportError: No module named MySQLdb with Python Flask, we install the mysql-python package.

To install it, we run

pip install mysql-python

Then we use

engine = create_engine('mysql+mysqldb://user:password@localhost/foo')

to connect to the database with create_engine.

Conclusion

To fix ImportError: No module named MySQLdb with Python Flask, we install the mysql-python package.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *