Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error loading MySQLdb module. Did you install mysqlclient? on MacOS

Am Trying to connect to my mysql db from django app. I get the below error during migration:

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

I've already installed mysqlclient as below:

Requirement already satisfied: mysqlclient in /usr/local/lib/python3.7/site-packages (1.4.2.post1)

I've also tried with pymysql and adding below code to ini.py file:

import pymysql
pymysql.install_as_MySQLdb()

Gives me some other errors. What could be wrong?

Python 3.7 , mysql 5.7 and Django 2.2 are my setup versions.

like image 693
Makamu Evans Avatar asked Mar 07 '26 15:03

Makamu Evans


1 Answers

I had the same issue. Running the below command fixed it for me.

pip install --force-reinstall --ignore-installed --no-binary :all: mysqlclient

like image 186
shawshank718 Avatar answered Mar 10 '26 04:03

shawshank718



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!