Error loading MySQLdb module.Did you install mysqlclient?


Full article


We are trying to use Django to connect to MySQL remote server.


There is a common error when connecting to an external MySQL database that even if you install in your environment all the mysql connectors, it will throw an error. This is the error:

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.Did you install mysqlclient?

If this information is useful to you, please click on one of my ads to help me with the cost of the website or so I can pay my classes. The ads are usually located on the right. Please ❤️


In your enviroment, run pip install pymysql

Then, edit the file in your project origin dir(the same as


import pymysql


Now try to connect again. If you get some weird error such as segmentation fault, check if you installed the connector via homebrew. The way they recommend to do it (which didn't work for me is this: If you installed that way via homebrew, just uninstall it (mysqlclient-python) and try to connect again.

Let me know if you have any questions below.