(py27) ➜ MySQL-python-1.2.3 python setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.7-x86_64-2.7/MySQLdb
running build_ext
building '_mysql' extension
gcc -fno-strict-aliasing -I/Users/kris/anaconda3/envs/py27/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/mysql/include -I/Users/kris/anaconda3/envs/py27/include/python2.7 -c _mysql.c -o build/temp.macosx-10.7-x86_64-2.7/_mysql.o -Os -g -fno-strict-aliasing -arch x86_64
In file included from /Users/kris/anaconda3/envs/py27/lib/gcc/x86_64-apple-darwin11.4.2/4.8.5/include-fixed/syslimits.h:7:0,
from /Users/kris/anaconda3/envs/py27/lib/gcc/x86_64-apple-darwin11.4.2/4.8.5/include-fixed/limits.h:34,
from /Users/kris/anaconda3/envs/py27/include/python2.7/Python.h:19,
from pymemcompat.h:10,
from _mysql.c:29:
/Users/kris/anaconda3/envs/py27/lib/gcc/x86_64-apple-darwin11.4.2/4.8.5/include-fixed/limits.h:168:61: fatal error: limits.h: No such file or directory
#include_next <limits.h> /* recurse down to the real one */
^
compilation terminated.
error: command 'gcc' failed with exit status
确保OSX已经安装xcode命令行工具:
xcode-select --install
确认接受弹出的对话框,进行安装。
That will install system headers into standard locations expected by tools like gcc, e.g./usr/include
.
重新pip install MySQLdb,安装成功。