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

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zydyyf.html