当前位置:   article > 正文

Python3 报错 Library not loaded: libmysqlclient.20.dylib

libmysqlclient.20.dylib

Python3 报错信息

Traceback (most recent call last):
  File "send.py", line 5, in <module>
    from db import *
  File "/Users/ko/projects/php/edm/db.py", line 7, in <module>
    import MySQLdb
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/__init__.py", line 19, in <module>
    import _mysql
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so, 2): Library not loaded: /usr/local/opt/mysql/lib/libmysqlclient.20.dylib
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so
  Reason: image not found
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

原因分析

昨天之行了一次 brew upgrade 导致 mysql、php 全部都错误。进入 /usr/local/opt/mysql/lib/ ,查看文件存在:

~$ ls -la  /usr/local/opt/mysql/lib/
total 22448
drwxr-xr-x   8 ko  staff      272  6 29 00:42 .
drwxr-xr-x  15 ko  staff      510  9  1 22:02 ..
-rw-r--r--   1 ko  staff  5424044  9  1 22:01 libmysqlclient.21.dylib
-r--r--r--   1 ko  staff  6047688  6 29 00:42 libmysqlclient.a
lrwxr-xr-x   1 ko  staff       23  6 29 00:42 libmysqlclient.dylib -> libmysqlclient.21.dylib
-r--r--r--   1 ko  staff     9624  6 29 00:42 libmysqlservices.a
drwxr-xr-x   3 ko  staff      102  9  1 22:01 pkgconfig
drwxr-xr-x  91 ko  staff     3094  6 29 00:42 plugin
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

解决方案

链接一个20版本到21

ln -s libmysqlclient.21.dylib libmysqlclient.20.dylib
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/人工智能uu/article/detail/951050
推荐阅读
相关标签
  

闽ICP备14008679号