mojave python 3.7 libmysqlclient.21.dylib问题

时间:2018-10-10 01:21:36

标签: mysql python-3.x

mojave python 3.7 libmysqlclient.21.dylib问题

File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/MySQLdb/__init__.py", line 18, in <module>
import _mysql
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_mysql.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libmysqlclient.21.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_mysql.cpython-37m-darwin.so
Reason: image not found

1 个答案:

答案 0 :(得分:0)

我的Python 3.6项目正在寻找libmysqlclient.21.dylib。

我安装了brew install mysql-client。它安装了mysql-client 8.0。它具有libmysqlclient.21.dylib。如我想使用mysql@5.6的地方。

所以我将libmysqlclient.21.dylib从/usr/local/Cellar/mysql-client/8.0.19/lib复制到/ usr / local / lib /

sudo ln -s /usr/local/Cellar/mysql-client/8.0.19/lib/libmysqlclient.21.dylib /usr/local/lib/libmysqlclient.21.dylib

因此,这是一个Python,mysql,mysqlclient版本不匹配的问题。

mysql@5.6具有libmysqlclient.18 mysql@5.7具有libmysqlclient.20

按照上述在Mac OSX Catalina中的解决方法。