Install mysqlclient on Mac

Author Avatar
Nathaniel Apr 08, 2018

Seriously, I’m pretty surprised that I have to write this down by myself. Why has nobody ever mentioned this on StackOverflow?

Prerequisite

Make sure you have Homebrew installed on your mac.

Steps

First, install XCode command line tools if you don’t have them.

$ xcode-select --install

Second, install openssl and mysql using brew.

$ brew install openssl mysql

Finally, set the SSL library path explicitly and install mysqlclient with pip.

$ LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient