Because I’m lazy to install Apache + MySQL + PHP separately, so in the first place, I use MAMP. But this becomes a problem when I’m going to install MySQLdb python library. Here is how to resolve it.
After downloaded the file MySQL-python-1.2.3.tar.gz, extract to a folder and edit one of the file setup_posix.py
mysql_config.path = "/Applications/MAMP/Library/bin/mysql_config"
Then add below line to ~/.bash_profile. This might be optional but for my case, I’ve added it and sourceit. This is because if not adding it, it will keep assume I’m using 64bit, but in fact, mine is 32bit only. You know you need to add this when you are getting error such as “mach-o, but wrong > architecture”
After that, execute the below command
python setup.py build python setup.py install
At this point, you have your library installed. But I’m getting error such as
Library not loaded: libmysqlclient.18.dylib
Referenced from: /Users/<user>/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
Reason: image not found
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
Above case, might need to install additional MySQL, seem MAMP doesn’t have library requested.