Mac 安装MySQLdb

https://pypi.python.org/pypi/MySQL-python/

下载最新的压缩包 zip

运行:

MacBook-Air:MySQL-python-1.2.5 huangyong$ python setup.py build

结果有一个警告

_mysql.c:1589:10: warning: comparison of unsigned expression < 0 is always false

[-Wtautological-compare]

if (how < 0 || how >= sizeof(row_converters)) {

~~~ ^ ~

1 warning generated.

clang -bundle -undefined dynamic_lookup build/temp.macosx-10.12-x86_64-2.7/_mysql.o -L/usr/local/Cellar/mysql/5.7.18_1/lib -L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/sqlite/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-x86_64-2.7/_mysql.so

运行

MacBook-Air:MySQL-python-1.2.5 huangyong$ sudo python setup.py install

结果正常。

然后:

MacBook-Air:MySQL-python-1.2.5 huangyong$ python

>>> import MySQLdb

import MySQLdb会有一些警告

>>> import MySQLdb

/usr/local/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-macosx-10.12-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/local/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-macosx-10.12-x86_64.egg/_mysql.pyc, but /Users/huangyong/Downloads/MySQL-python-1.2.5 is being added to sys.path



MySQL-python-1.2.5没用了,可以删了

你可能感兴趣的:(Mac 安装MySQLdb)