sensimevanidus

1 February, 2012

Installing MySQLdb Python module on MacOSX

I created an empty project for Django. It uses MySQL server; but when I wanted to run the application I got an exception that contained the following line (I won’t paste all of the traceback message):

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

When it comes to installing such libraries, packages, etc. on MacOSX, I find myself using MacPorts. So, the easiest way (at least for me) is using MacPorts. Be sure that you’ve installed MacPorts and on terminal, write the following:

sudo port install py27-mysql

MacPorts will add appropriate directories to the PATH environment variable automatically. Don’t forget to use the command python2.7 instead of python from now on.

That’s all about it!