问题:
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/anaconda3/envs/LearnDjango/lib/python2.7/site-packages/MySQLdb/__init__.py", line 18, in <module>
import _mysql
ImportError: dlopen(/anaconda3/envs/LearnDjango/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: @rpath/libmysqlclient.21.dylib
Referenced from: /anaconda3/envs/LearnDjango/lib/python2.7/site-packages/_mysql.so
Reason: image not found
解决办法:
1、关闭csrutil
2、找到mysql安装路径,建立软连接
sudo ln -s /usr/local/mysql/lib/libmysqlclient.21.dylib /usr/lib/libmysqlclient.21.dylib
安装mysqlclient, 链接mysql失败,提示“Library not loaded: @rpath/libmysqlclient.21.dylib”
原文:https://www.cnblogs.com/tim-eff/p/9607472.html