>>> 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