[Solved] ModuleNotFoundError: No module named ‘MySQLdb’

Resolve modulenotfounderror: no module named ‘mysqldb’

System: Ubuntu 18.04

First, check the error reports:

There are two ways to Solve this error:

One is to use pymysql and add two lines of code, but because the code has been uploaded to the server and the modification is complex, the second method is adopted: install mysqlclient, and execute the following command:

pip3 install mysqlclient

report errors:

After Google again, I found that libmysqlclient dev needs to be installed first

apt-get install libmysqlclient-dev

PIP installation again, successful!

Similar Posts: