Error Loading MySQLdb Module and "pip install MySQLdb"

Clearly installing pip install MySQL-python is the way to go. The problem is with the location of mysql_config. Look around here, this might help you depending on your OS: mysql_config not found when installing mysqldb python interface

Edit:

In case the install script fails with Command "python setup.py egg_info" failed with error code 1 in {...}, installing libmysqlclient-dev with

sudo apt install libmysqlclient-dev

should fix the issue. Thanks to @thirupathi-thangavel.


brew install mysql

Path will be shown after installation is complete, use that in below command :

sudo PATH=/usr/local/Cellar/mysql/bin/:$PATH pip install mysql-python