報錯內容主要是:
EnvironmentError: mysql_config not found
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/nh/j05szmpj19368dd9_y6whgy40000gq/T/pip-install-n9Jonx/mysql-python/
網上查了執行一個什么環境變量的命令:
export PATH=$PATH:/usr/local/mysql/bin
然后報了另一個錯:
#include "my_config.h"
^~~~~~~~~~~~~
1 error generated.
error: command 'cc' failed with exit status 1
最后用了兩個方法
一是先執行:
brew install mysql
注意一定要是通過brew安裝
二是直接去下載:
https://dev.mysql.com/downloads/connector/python/
下載完以后,通過finder可以訪問到:
/usr/local/mysql/bin 這個文件夾,可以看到里面是有一個叫 mysql_config 的文件
由於我是同時做了這兩件事的,所以無法判斷到底哪個是對哪個是錯,或者都可以,然后再執行一遍:
export PATH=$PATH:/usr/local/mysql/bin
最后再執行 pip install MySQL-Python 就好了
參考:
https://stackoverflow.com/questions/25459386/mac-os-x-environmenterror-mysql-config-not-found