当前位置:  编程技术>python

MySQLdb ImportError: libmysqlclient.so.18解决方法

    来源: 互联网  发布时间:2014-10-10

    本文导语:  安装MySQLdb后,import MySQLdb出错如下: 代码如下: [root@lizhong MySQL-python-1.2.3]# /usr/local/bin/python2.7 Python 2.7.6 (default, Apr 10 2014, 15:45:39) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>...

安装MySQLdb后,import MySQLdb出错如下:

代码如下:

[root@lizhong MySQL-python-1.2.3]# /usr/local/bin/python2.7
Python 2.7.6 (default, Apr 10 2014, 15:45:39)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
/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

根据最后提示,应该是找不着一个交libmysqlclient.so.18的文件,于是到mysql安装目录里找到这个文件并且做一个软连接到/usr/lib
代码如下:

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

如果是64系统则:
代码如下:

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

再次import MySQLdb就正常了:
代码如下:

[root@lizhong MySQL-python-1.2.3]# /usr/local/bin/python2.7
Python 2.7.6 (default, Apr 10 2014, 15:45:39)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>>

    
 
 

您可能感兴趣的文章:

 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • Python的MySQLdb模块安装
  • python mysqldb连接数据库
  • Python下的Mysql模块MySQLdb安装详解
  • python使用mysqldb连接数据库操作方法示例详解


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    数据库 iis7站长之家