一.安装
先安装python setup.py需要的setuptools
yum install python-setuptools
MySQLdb模块
下载
wget https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.5.zip
安装
unzip MySQL-python-1.2.5.zip
cd MySQL-python-1.2.5
python setup.py build
(报错见下面)
python setup.py install
OK
二.报错及解决方法
python setup.py build 时候
错
Error: mysql_config not found 找不到mysql_config
解决
find / -name mysql_config /data/mysql5537/bin/mysql_config
修改setup_posix.py文件,在27行:
mysql_config.path = “mysql_config” 修改为:
mysql_config.path = "/data/mysql5537/bin/mysql_config"
错
错误:Python.h:没有那个文件或目录 缺少python的开发
yum install python-devel
错 执行python 1Sql.py时候报错
ImportError: libmysqlclient.so.18错误 ,找不到mysql的so文件
ln -s /data/mysql5536/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18