python 下安装 MySQLdb 填坑

在新版的 mac 下安装一些库的时候出现 ld: library not found for -lssl 等类似的错误信息。
说库里缺少链接,还有其他的等等。其实都和 xcode 有关系
参考

1
2
3
4
cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. build/temp.macosx-10.12-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql/5.7.17/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-intel-2.7/_mysql.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'cc' failed with exit status 1

解决办法:
在 cmd 下执行下面命令

1
xcode-select --install

查看是否安装成功

1
xcode-select -p

此时再安装

1
2
3
4
5
6
7
8
sudo  pip install mysql-python 

Collecting mysql-python
Downloading MySQL-python-1.2.5.zip (108kB)
100% |████████████████████████████████| 112kB 427kB/s
Installing collected packages: mysql-python
Running setup.py install for mysql-python ... done
Successfully installed mysql-python-1.2.5