在 Mac OS X 下安装 python-mysql
安装方法有多种,你可以按照这个。下载mysql-connector-python-2.0.4-osx10.9.dmg也可以
pip3 install --allow-external mysql-connector-python mysql-connector-python
两行命令不就解决了吗?
$ brew install mysql-connector-c
$ sudo pip install MySQL-python
嗯,也是被坑了个2小时。解决方法:先把之前装的卸载干净:
pip uninstall mysql-python
brew uninstall mysql-connector-c
现在设置下mysql_config路径:
首先修改系统配置文件
vim ~/.bash_profile
或者有些人是
~/.profile,export
PATH=$PATH:/Applications/MAMP/Library/bin
这里/Applications/MAMP/Library/bin是MAMP的mysql配置文件路径
安装
brew install mysql-connector-c
pip install mysql-python
我也遇到了这个问题。不过我用的是python3.5,该版本不支持mysqldb。使用pymysql或者mysql.connector替代。
命令:
pip install pymysql