mac下import MySQLdb报错Library not loaded

本地将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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值