最后换了一个MIT出的mysql接口pymysql,问题解决,流程如下:
Anaconda comes with the conda installer, so use conda instead of pip. This works for all packages that are available for conda. There are MySQL packages available, you can select them from https://docs.continuum.io/anaconda/pkg-docs.
For pymysql you open up the command line, call 'conda install pymysql' and watch the magic unfold.
There is of course a trade-off (for the not-gurus like me at least): there are also packages that are not available for conda. tweepy is one of those. On the other hand, I did not manage to get sklearn installed using pip after uninstalling anaconda as suggested in the other answer.
[Edit:]I could install tweepy after searching on https://anaconda.org
[Edit, in response on question:] @scottlittle,you mean something like:
# -*- coding: utf-8 -*-
# imports
import pymysql
# open connection to the database
conn = pymysql.connect(host='localhost',
port=3306,
user='',
passwd='',
db='',
charset='utf8')
cur = conn.cursor()
sql = "SELECT * FROM "
cur.execute(sql)
# close connection to the database
cur.close()
conn.close( )