sqldump

(coffee) => code

Django on Mac = FAIL

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. 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:

1
2
3
4
5
# install django and dependencies
sudo port install py26-django
# set py26 as default
sudo port select --set python python26
sudo port install py26-mysql

Just to make sure these worked:

1
2
3
4
5
6
7
8
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)
>>>