Installing MySQL Python on Mac OS X

Another option is to use pymysql it is a pure Python client connection to MySQL so you don't have to mess around with compiling, a good exercise, but it can be frustrating if you are just trying to get something done. pymysql follows the same API as MySQLdb, it can essentially be used as a drop in replacement.

Also, it used to be that MySQLdb, did not work with Python 3, but this may have changed, pymysql didn't have that problem which also induced me to switch, this may have changed though. pymysql can be slower than MySQLdb but you'll have to see if you notice that, it is also under a different license (MIT for pymysql, GPL for MySQLdb)


Here's what I would install, especially if you want to use homebrew:

  • XCode and the command line tools (as suggested by @7stud, @kjti)
  • Install homebrew
  • brew install mysql-connector-c
  • pip install mysql-python