Skip to content

Instantly share code, notes, and snippets.

@blanklin030
Last active April 10, 2019 15:30
Show Gist options
  • Save blanklin030/256434228f0e1785192770590e7eb860 to your computer and use it in GitHub Desktop.
Save blanklin030/256434228f0e1785192770590e7eb860 to your computer and use it in GitHub Desktop.
在mac下pip install MySQL-python提示 _mysql.c:44:10: fatal error: 'my_config.h' file not found的解决方法

在mac下使用pip安装mysql扩展包时出错

 _mysql.c:44:10: fatal error: 'my_config.h' file not found
    #include "my_config.h"
             ^~~~~~~~~~~~~
    1 error generated.
    error: command 'clang' failed with exit status 1

解决方法

brew install mysql #若已安装mysql,则跳过此步
brew unlink mysql
brew install mysql-connector-c
sed -i -e 's/libs="$libs -l "/libs="$libs -lmysqlclient -lssl -lcrypto"/g' /usr/local/bin/mysql_config
pip install MySQL-python
brew unlink mysql-connector-c
brew link --overwrite mysql

若未安装mysql可参考链接

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