Django is awesome. Python is awesome. Mac OS is sort-of ok. So is MySQL. But geez, getting Pythonâs MySQL connector (MySQLdb) to play nice on the Mac OS made me start to lose my hair, bit by bit. Django needs this to be able to reach a MySQL server (which I wanted to use) to be able seamlessly run syncdb etc.
There are varied sets of sparse instructions all over the interwebs on how to get MySQL db to compile for Mac OS; some ask you to edit source files before compiling, some are out of date and nearly all of them just donât work.
ButâŠitâs a MacâŠdoesnât it just work?! Apparently not. </end rant>
The solution, this time, came to me in the form of MacPorts. MacPorts is a brilliant system that is the closest replacement to aptitude, for someone coming from a more Ubuntu-esque background (and I guess its existence makes sense, what with FreeBSD ports and all). A few simple lines to get you going on this:
sudo port install py26-django # install django and dependencies sudo port select --set python python26 # set py26 as default sudo port install py26-mysql
Just to make sure these worked:
macbookpro:~ asdf$ python Python 2.6.6 (r266:84292, May 26 2011, 01:52:07) [GCC 4.2.1 (Apple Inc. build 5664)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import MySQLdb >>> MySQLdb.version_info (1, 2, 3, 'final', 0) >>>