python环境已经安装好,版本为2.7.8,需要调用数据库,所以需要安装MysqlDB模块包

下载地址:http://download.csdn.net/download/fhqsse220/5602861

安装过程:

  1. 解压及安装

    # tar -xf MySQL-python-1.2.3.tar.gz 

    #cd MySQL-python-1.2.3

    #python setup.py build

    #python setup.py install

2.错误解决

  导入模块报错:

  

/usr/local/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/local/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/_mysql.pyc, but /soft/MySQL-python-1.2.3 is being added to sys.path

Traceback (most recent call last):

  File "", line 1, in

  File "MySQLdb/__init__.py", line 19, in

    import _mysql

  File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, in

  File "build/bdist.linux-x86_64/egg/_mysql.py", line 6, in __bootstrap__

ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory


创建动态库的链接:

ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18

&

ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18


重新导入:

/usr/lib/python2.4/site-packages/MySQL_python-1.2.3-py2.4-linux-i686.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/lib/python2.4/site-packages/MySQL_python-1.2.3-py2.4-linux-i686.egg/_mysql.pyc, but /root/soft/MySQL-python-1.2.3 is being added to sys.path


离开当前目录,因为当前目录有相关模块