如果你服务器环境允许yum,安装MySQL-python模块就很简单了
[python]view plaincopy
yuminstallMysqL-python-y
当然也可以源码安装该模块
首先安装setuptools,下载源代码包:
wgethttp://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
解压后
pythonsetup.pybuild
pythonsetup.pyinstall
然后安装一些扩展库
[plain]
yum-yinstallrpm-buildgcc-c++mysql-develpython-devel 最后安装MySQL-python
下载源代码包: wgethttp://download.sourceforge.net/sourceforge/MysqL-python/MysqL-python-1.2.3.tar.gz 解压进入安装目录。 编辑site.cfg,把MysqL_config那一行取消注释,并改为: pythonsetup.pybuild pythonsetup.pyinstall [root@woyoo:/tmp/MysqL-python-1.2.3]#python Python2.6.6(r266:84292,Feb222013,00:00:18) [GCC4.4.720120313(RedHat4.4.7-3)]onlinux2 Type"help","copyright","credits"or"license"formoreinformation. >>>importMysqLdb /usr/lib64/python2.6/site-packages/MysqL_python-1.2.3-py2.6-linux-x86_64.egg/_MysqL.py:3:UserWarning:Module_MysqLwasalreadyimportedfrom/usr/lib64/python2.6/site-packages/MysqL_python-1.2.3-py2.6-linux-x86_64.egg/_MysqL.pyc,but/tmp/MysqL-python-1.2.3isbeingaddedtosys.path >>>
测试安装