用Python3连接MySQL数据库时需要用到MySQL模块,但是Python3并没有自带MySQL模块,需要自行安装,也就是MySQL for Python(MySQL-python)。
在终端输入:(默认你已经安装了pip)
pip install MySQL-python如果遇到:error: command 'cc' failed with exit status 1
这个问题,就用下面这个命令:
xcode-select --install等待几分钟安装成功后,再输入:
pip install MySQL-python
终端输入:
python3
>>>import pymysql没有报错就可以了。。。。。。。。