本地将homebrew更新后,在使用python的时候出现了问题:
import MySQLdb
File "/usr/local/lib/python2.7/site-packages/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/lib/python2.7/site-packages/_mysql.so
Reason: image not found
大概意思就是_mysql.so依赖/libssl.1.0.0.dylib,但是到/usr/local/opt/openssl/lib/文件夹看,发现只有libcrypto.1.1.dylib,应该是更新homebrew之后连带着将openssl也更新了。
解决办法,重新安装libssl.1.0.0:
brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb(安装指定版本)
在此之前,也可以先brew uninstall openssl
安装之后,发现/usr/local/Cellar下既有openssl@1.1也有openssl文件夹,此时再运行python,不再报错。
参考资料:
https://www.jianshu.com/p/470ae2f77b6e 这里主要介绍了mac下的好用工具:otool -L和install_name_tool