Install `mysqlclient` on Mac

Author Avatar
Nathaniel Apr 08, 2018

I feel like I have to write this down because it’s so hard to find a solution that really works 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