Installing mysql-python in Mac OS X 10.6.7 Snow Leopard

Installing mysql-python in my Mac OS X 10.6.7 Snow Leopard was a painful experience. After some hours of trial and error and googling I got it working. Here are the steps:

1. Make sure you have gcc installed. I installed Xcode 3.2.6 which is the Apple’s development environment and it includes gcc. I lost my DVD somewhere. So I had to download it from their website. It’s around 4.4 GB. In the process of installing it, it might ask you to close your iTunes and might keep asking you even if iTunes is closed. You will have to close iTunesHelper to continue the installation. Open Activity Monitor (located in Applications/Utilities) and quit it from the list of processes.

2. Download the mysql-python tar.gz file from here. Untar it and then build and install it. To do this (assuming that you have uncompressed the tar.gz file and pointed your terminal to the uncompressed directory):

$ sudo su
# python setup.py build
# python setup.py install

3. Finally, add your mysql lib directory in DYLD_LIBRARY_PATH. You can add the following line in your .bash_profile file modifying your mysql directory location.

export DYLD_LIBRARY_PATH='/usr/local/mysql-5.5.25-osx10.6-x86_64/lib/'

4. Now, in your python interactive console try to import MySQLdb. If there is no error you are done! Otherwise please google 😉 These steps worked for me.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: