Skip to content

Instantly share code, notes, and snippets.

@Shawn1224
Last active August 23, 2021 13:41
Show Gist options
  • Save Shawn1224/2d287557470204d08cc3c610314ad162 to your computer and use it in GitHub Desktop.
Save Shawn1224/2d287557470204d08cc3c610314ad162 to your computer and use it in GitHub Desktop.
Install mysqlclient(Python package) on macOS

Try this first.

brew install mysql-connector-c
sudo pip install MySQL-python

If fail then try below.

brew unlink mysql
brew install mysql-connector-c
vi /usr/local/bin/mysql_config

Found a line with libs="$libs -l" replace it by

libs="$libs -lmysqlclient -lssl -lcrypto"

pip install mysqlclient


brew reinstall mysql-connector-c

echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"

source .bash_profile
@Shawn1224
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment