Sunday, March 21, 2010

Installing MySQLdb on Snow Leopard

This is completely useless if you don't want to install a connector between Python and MySQL on a Mac.

If you did need to and didn't want to spend hours searching for how to do it - this is the solution (after a stupid amount of time looking on and off over the last couple of months).

Spent ages trying to install this component on Snow Leopard.

Firstly - Snow Leopard removed one of the old gcc compilers (needed to build the package). This needs to come off the installation DVD.

Secondly - MySQLdb has the wrong config path in site.cfg. You need to change it. It's in /usr/local. You need to tell it the path to the mysql config file (in bin inside the mysql install directory).

Thirdly - there's something necessary called an Arch flag. Don't know what that is.

Fourthly - MySQLdb is calling the wrong version of gcc so you need to correct that.

Therefore instructions are:
Download latest version from sourceforge.

Now go into the relevant directory through terminal and:
sudo python clean
sudo ARCHFLAGS=’-arch x86′ CC=/usr/bin/gcc-4.0 python build
sudo ARCHFLAGS=’-arch x86′ CC=/usr/bin/gcc-4.0 python install

Overly complicated but worked in the end.

Found the instructions in the comments halfway down the article linked.

No comments:

Post a Comment