到
https://pypi.python.org/pypi/MySQL-python/
下載最新的壓縮包 zip
運行:
MacBook-Air:MySQL-python-1.2.5 huangyong$ python setup.py build
結(jié)果有一個警告
_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
結(jié)果正常秘蛇。
然后:
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沒用了,可以刪了