美文网首页
缺失libmysqlclient.so.18

缺失libmysqlclient.so.18

作者: desperado_wen | 来源:发表于2019-11-07 10:04 被阅读0次

    一 问题描述
    更新数据库后重启Django项目,返回500.查看日志文件发现报错。

    your processes number limit is 516551
    your memory page size is 4096 bytes
    detected max file descriptor number: 1024
    lock engine: pthread robust mutexes
    thunder lock: disabled (you can enable it with --thunder-lock)
    uwsgi socket 0 bound to UNIX address /tmp/indel.sock fd 3
    Python version: 3.5.3 (default, Sep 27 2018, 17:25:39)  [GCC 6.3.0 20170516]
    Python main interpreter initialized at 0x558d197a9a80
    python threads support enabled
    your server socket listen backlog is limited to 100 connections
    your mercy for graceful operations on workers is 60 seconds
    mapped 1191168 bytes (1163 KB) for 64 cores
    *** Operational MODE: preforking+threaded ***
    Traceback (most recent call last):
      File "....../venv/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 15, in <module>
        import MySQLdb as Database
      File "....../venv/lib/python3.5/site-packages/MySQLdb/__init__.py", line 19, in <module>
        import _mysql
    ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory
    

    是导入MySQLdb模块时报的错。
    二 解决过程
    激活环境

    source venv/bin/activate
    Python 3.5.3 (default, Jan 19 2017, 14:11:04)
    [GCC 6.3.0 20170118] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import MySQLdb
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "....../venv/lib/python3.5/site-packages/MySQLdb/__init__.py", line 19, in <module>
        import _mysql
    ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory
    

    本机寻找

    sudo find / -name libmysqlclient.so.18
    sudo locate libmysqlclient.so.18
    

    找不到...(如果找到了,软链接到ln -s 找到的libmysqlclient.so.18文件路径 /usr/lib/libmysqlclient.so.18
    在这个页面download path(es页面)找libmysqlclient.so.18的下载地址
    sudo wget -O /usr/lib/libmysqlclient.so.18 http://files.directadmin.com/services/es_7.0_64/libmysqlclient.so.18
    成功解决

    $ python
    Python 3.5.3 (default, Jan 19 2017, 14:11:04)
    [GCC 6.3.0 20170118] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import MySQLdb
    >>>
    

    重启后没有问题。
    三 解决方法
    1,sudo wget -O /usr/lib/libmysqlclient.so.18 http://files.directadmin.com/services/es_7.0_64/libmysqlclient.so.18
    2,重启项目。

    相关文章

      网友评论

          本文标题:缺失libmysqlclient.so.18

          本文链接:https://www.haomeiwen.com/subject/sssmbctx.html