It was Complicated and hard but it worked on MacOSX Lion.
you will be using :
Xcode
Brew
Port
Pip
make sure that you have Xcode(4.X) installed , and your mac is configured to find the executables because it will be used by Macports during the process of installing mysql-python.
Make sure that Xcode Command line Tools are installed
start Xcode app >> preferences >> download >> Components tab >> Command Line Tools >> click install
run the following commands from the terminal.
xcodebuild -version
if you ran into this error
/usr/bin/xcodebuild -version Error: No developer directory found at /Developer
Try to Run
/usr/bin/xcode-select
this will update the developer directory path.
Then you need to switch manually to the new Xcode install dir in /Applications:
sudo /usr/bin/xcode-select -switch /Applications/Xcode.app
Ref
Uninstall mysql [Backup you data before doing so !].
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*
Use brew to install Mysql again:
brew install mysql
you might run into this error.
Error: Cannot write to /usr/local/Cellar
the fix.
you should be ready to go now.
sudo port install py27-mysql
pip install mysql-python
python -c "import MySQLdb"
if you don't see any errors MySQLdb is installed.