mac下 python2.7安装MySQL-python总结

mac下 python2.7安装MySQL-python碰到很多问题:

1. pip install MySQL-python 总是报这个错

Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/2w/tt1p_4td3yq9xlbl7c2t4jn00000gn/T/pip-install-TkmPbl/MySQL-python/

2. 使用安装包安装时,却总是报这个

_mysql.c:35:10: fatal error: 'my_config.h' file not found
#include "my_config.h"

 百度搜了很多文章都没能解决这个问题,都千篇一律 。。。

 

最终用这种方法解决,顺手记下来,希望能有所帮助

brew install mysql
brew unlink mysql
brew install mysql-connector-c #或者已经安装了的话  brew link 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

参考链接:

https://stackoverflow.com/questions/12218229/my-config-h-file-not-found-when-intall-mysql-python-on-osx-10-8/12233148 

你可能感兴趣的:(python)