Yesterday I started a project using Django and I wanted to use MySQL. Since I bought my Mac a month ago, I didn’t get chance to install all Python MySQL egg. Then I noticed that Leopard has some issues with installing Python MySQL egg. I don’t know maybe it was because of changing to Python 2.6. Anyways, here is how I solved my problem after a little googling.
If you are having same problem installing (even with MacPorts), here is how you do:
First of all, you need to download the actual source for mysql-python. I used MySQL-python-1.2.2 version. Then extract the contents of the file to a location, and open this location up in the Terminal.
From this point, it’s going to be a little tricky. You need to edit _mysql.c file. Open the file in any text editor and remove following lines somewhere close to line 40:
#define uint unsigned int
#endif
And change the following lines (line 480ish):
uint client_flag = 0;
#change above lines to
unsigned int port = MYSQL_PORT;
unsigned int client_flag = 0;
Create a symbolic link to all of the files in the lib directory under a directory called mysql in lib by:
After this step, you need to build the egg again and install it:
$ sudo python setup.py install
That’s it. I hope it helps..
Edit: Make sure you’re using 32bit version of MySQL










Hi, thanks for the post. It seems that this has been resolved with MySQL-python-1.2.3c1, at least the edit of _mysql.c part.
Regardless, I’m back in action. Thanks.
Stu
August 5, 2009, 12:05 AM