安装mysqlclient, 链接mysql失败,提示“Library not loaded: @rpath/libmysqlclient.21.dylib”
Posted 六月骄阳
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装mysqlclient, 链接mysql失败,提示“Library not loaded: @rpath/libmysqlclient.21.dylib”相关的知识,希望对你有一定的参考价值。
问题:
>>> 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”的主要内容,如果未能解决你的问题,请参考以下文章
pychar安装第三方库MySQL/mysqlclient报错:error: Microsoft V
Python django 安装 mysqlclient 失败
Django报错“Did you install mysqlclient or MySQL-python?”的解决办法(前提:mysqlclient&MySQL都已经安装)