在安装MySQL之后和mysql-connector-c之后,安装MySQLdb
sudo pip install setuptools; //Python标准的打包及分发工具
sudo pip install tokenize;
问题1:python mysql_config: command not found
mysql_config命令未找到,进入用户根目录设置PATH
touch .bash_profile
// 编辑内容 PATH=$PATH:/usr/local/Cellar/mysql/5.7.21/bin
source .bash_profile
问题2:Running setup.py install for MySQL-python … error
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-gkffZ3/MySQL-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-pQ0TCV-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-gkffZ3/MySQL-python/
解决:
brew install mysql-connector-c
安装失败可以使用pymysql