mac python 出现 “Abort trap: 6” 问题

0. 现象

python 程序自动退出

  • 命令行下显示 Abort trap: 6
  • pycharm 显示 Process finished with exit code 134 (interrupted by signal 6:SIGABRT)

1. 查看 python 日志

日志位置 ~/Library/Logs/DiagnosticReports,有 .crash 后缀的日志文件

Application Specific Information:
/usr/lib/libcrypto.dylib
abort() called
Invalid dylib load. Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI.

2. 原因

如日志所说,libcryptodylibunversioned

3. 解决办法

注意下面但位置不一定是 /usr/local/Cellar/openssl/1.0.2t/lib,比如我的环境就是 /usr/local/Cellar/openssl/1.0.2q/lib

brew update && brew upgrade && brew install openssl
## note: some people report that the dylib files needed in #3 are in the 1.0.2t folder, rather than the lib folder. adjust your path in #2 as needed.
cd /usr/local/Cellar/openssl/1.0.2t/lib
sudo cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib /usr/local/lib/
cd /usr/local/lib
sudo ln -s libssl.1.0.0.dylib libssl.dylib
sudo ln -s libcrypto.1.0.0.dylib libcrypto.dylib

替换后再运行就行了

参考 & 其他解决方案 (可忽略)

  • https://github.com/pypa/pip/issues/7254
  • https://forums.developer.apple.com/thread/119429
This is related to pyopenssl using old dependencies. 
You can fix it by removing the cryptography package, then upgrading cryptography to version 2.8.
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐