MACOS 安装mysqlclient 的 Library not loaded错误

报错场景

>>> import MySQLdb
Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/xxx/.local/share/virtualenvs/MyDjango-c9TXLMy3/lib/python3.6/site-packages/MySQLdb/__init__.py", line 18, in 
    from . import _mysql
ImportError: dlopen(/Users/xxx/.local/share/virtualenvs/MyDjango-c9TXLMy3/lib/python3.6/site-packages/MySQLdb/_mysql.cpython-36m-darwin.so, 2): Library not loaded: libcrypto.1.0.0.dylib

类似的还有Library not loaded: libssl.1.0.0.dylib, Library not loaded: @rpath/libmysqlclient.21.dylib等

解决方案

从mysql安装路径的lib目录下将相应的依赖库链接到/usr/local/lib/下

ln -s /usr/local/mysql/lib/libmysqlclient.21.dylib /usr/local/lib/libmysqlclient.21.dylib
ln -s /usr/local/mysql/lib/libssl.1.0.0.dylib /usr/local/lib/libssl.1.0.0.dylib
ln -s /usr/local/mysql/lib/libcrypto.1.0.0.dylib /usr/local/lib/libcrypto.1.0.0.dylib

转载于:https://www.cnblogs.com/Peter2014/p/10937563.html

你可能感兴趣的:(MACOS 安装mysqlclient 的 Library not loaded错误)