centos 6.5 安装MySQL-python模块

前端之家收集整理的这篇文章主要介绍了centos 6.5 安装MySQL-python模块前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

如果你服务器环境允许yum,安装MySQL-python模块就很简单了

[python]view plaincopy

在CODE上查看代码片

派生到我的代码片

  1. yuminstallMysqL-python-y



当然也可以源码安装该模块

首先安装setuptools,下载源代码包:

[plain]

派生到我的代码片

  1. wgethttp://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz

  2. 解压后

  3. pythonsetup.pybuild

  4. 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那一行取消注释,并改为:

  • MysqL_config=/usr/lib64/MysqL/MysqL_config(根据自己MysqL安装位置定义)

  • 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

  • >>>

  • 报出一大堆警告信息,解决办法:删除MysqL-python源目录,再测试一下:

    猜你在找的CentOS相关文章