installing mysql-python on mac

Tue Feb 18, 2014

Awesome next challenge - running a flask server to connect to a MAMP [2.1.3] sql server on a mac (mavericks). Flask is a light weight python server and uses flask-sqlalchemy to connect. Installing mysql-python seems to be a challenge.

#assuming you've already installed xcode & homebrew
brew install mysql   #use brew install mysql --universal if your not using 64bit

Go to dev mysql
download the latest release and decompress the file.

cd /path/to/download/
tar -xvf mysql-*.tar.gz
cd /path/to/extract/
mkdir /Applications/MAMP/Library/include
cp -r include/* /Applications/MAMP/Library/include
cp -r lib/* /Applications/MAMP/Library/lib

export ARCHFLAGS="-arch $(uname -m)"
export PATH=$PATH:/Applications/MAMP/Library/bin
export DYLD_LIBRARY_PATH=/Applications/MAMP/Library/lib

sudo easy_install mysql-python

FYI: this line will cause trouble with git

export DYLD_LIBRARY_PATH=/Applications/MAMP/Library/lib

Rebooting your computer will clear it.

On a side note, when your connecting to the MAMP sql, python may complain mysql.sock is missing. It is located under


Additional Source