1:安装MySQLdb
首先要保证已经正确安装了mysql。
1):下载MySQL-python-1.2.3.tar.gz(具体版本依据python的版本而定)
2): 解压 tar -zxvf MySQL-python-1.2.3.tar.gz
3): 编译 ,进入到解压目录MySql-python-1.2.3。执行python setup.py build
4): 在安装过程中可能会提示缺少setuptools。如果是Linux可以用如下方式安装
wget https://bootstrap.pypa.io/ez_setup.py -O - | python。
我在安装中还遇到过错误:
error: command 'gcc' failed with exit status 1
解决办法:
yum install python-devel
扫描二维码关注公众号,回复:
471843 查看本文章
以上都OK之后,继续执行python setup.py build
5): 执行python setup.py install。
参考:http://www.redicecn.com/html/Python/20110417/250.html