David Cramer's Blog

MySQLdb on Leopard

As many people probably have, I ran across the problem of installing MySQLdb (Python) on Leopard today.

The error:

In file included from /usr/local/mysql/include/mysql.h:43,
from _mysql.c:40:
/usr/include/sys/types.h:92: error: duplicate 'unsigned'
/usr/include/sys/types.h:92: error: two or more data types
in declaration specifiers
error: Setup script exited with error: command 'gcc' failed
with exit status 1

Luckily, there are people out there who know a lot more than me about these things, and someone had already found a fix:


To get mysqldb working on leopard I found I had to edit _mysql.c and edit out the lines:

#ifndef uint
#define uint unsigned int
#endif

I also had to edit site.cfg and mark threadsafe to False.


After doing this, I managed to get MySQLdb to install, great! Not so fast, there was yet another problem:


Referenced from: .../_mysql.so
Reason: image not found

The solution:


sudo ln -s /usr/local/mysql/lib/ /usr/local/mysql/lib/mysql