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

I run into this error pretty regularly on macOS after upgrading (or downgrading) MySQL using homebrew. The error message is confusing, because I have installed the mysqlclient Python package—it’s just failing to load properly.

The problem is your pip cache has a mysqlclient built with the wrong MySQL version, and pip keeps reinstalling that.

To fix, force pip to rebuild it ignoring the cache:

pip install --force --no-cache mysqlclient==<version>
3 Likes