fir3net
PPS-Firenetbanner-780.5x190-30-03-17

Python - No module named MySQLdb

Issue

When trying to import MySQLdb you may find that the module is not available. And experience an error such as,

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: 
No module named MySQLdb

Solution

The solution is to install MySQL-python i.e

pip-2.7 install MySQL-python

PIP INSTALL Error

However, when trying to install MySQL-python you may then get the following error,

pip-2.7 install MySQL-python
...
error:Setup script exited with error: command 'gcc' failed with exit status 1

To fix this issue install the following,

yum install mysql-devel

Tags: Python, Yum, MySQL

About the Author

RDonato

R Donato

Rick Donato is the Founder and Chief Editor of Fir3net.com. He currently works as a Principal Network Security Engineer and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001