python2.7 Referenced from: /usr/local/lib/libmysqlclient.18.dylib
ImportError: dlopen(/Users/chennan/Library/Python/2.7/lib/python/site-packages/_mysql.so, 2): Library not loaded: @rpath/libmysqlclient.18.dylib
Referenced from: /Users/chennan/Library/Python/2.7/lib/python/site-packages/_mysql.so
Reason: image not found
首先确定自己是否安装mysql,没有的话
brew install mysql
brew install mysql-connector-c
查看_mysql.so的引用动态链接库有哪些。
/Users/chennan/Library/Python/2.7/lib/python/site-packages/_mysql.so:
@rpath/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
解决方案使用mdfind命令找到libmysqlclient.18.dylib的位置然后拷入到 /usr/local/lib/目录下。
之后还会提示其他.dylib找不到多复制几次就好了。
最新发现安装完mysql之后没有找到libmysqlclient.18.dylib,搜遍电脑也没有,但是发现了libmysqlclient.20.dylib,所以我找到它以后改名为18.
最后执行
sudo install_name_tool -change libmysqlclient.18.dylib /Users/chennan/Library/Python/2.7/lib/python/site-packages/_mysql.so