-->

Python crashing on MacOS 10.15 Beta (19A582a) with

2020-02-16 08:39发布

问题:

I ran my Django project with new macOS Catalina and was running fine.
I installed oh_my_zsh then I tried to run the same project it is crashing with the following errors. I uninstalled oh_my_zsh and tried again but it did not worked.

Path:                  /usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python
Identifier:            Python
Version:               3.7.4 (3.7.4)
Code Type:             X86-64 (Native)
Parent Process:        Python [7526]
Responsible:           Terminal [7510]
User ID:               501

Date/Time:             2019-10-07 20:59:20.675 +0530
OS Version:            Mac OS X 10.15 (19A582a)
Report Version:        12
Anonymous UUID:        CB7F20F6-96C0-4F63-9EC5-AFF3E0989687


Time Awake Since Boot: 3000 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

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.

回答1:

I just came across the same problem and felt a bit uncomfortable to manually link things around.

I was able to solve the problem by simply

  1. Installing openssl via homebrew:
    brew install openssl
    
  2. Pointing towards the dynamic libraries from openssl via DYLD_LIBRARY_PATH:
    export DYLD_LIBRARY_PATH=/usr/local/opt/openssl/lib:$DYLD_LIBRARY_PATH
    

I've just added that line to my .zshrc.

Edit: According to this question, the usage of DYLD_FALLBACK_LIBRARY_PATH might be preferable over DYLD_LIBRARY_PATH.



回答2:

Caveat: I am not a security expert, and this solution messes with crypto libraries!

I don't think your issue stems from zsh or oh-my-zsh. My best guess: some crypto libraries installed with MacOS 10.15 are incompatible with Homebrew's python3 installation.

Here's what fixed the issue for me

# Install openssl via homebrew.
# Note: According to homebrew, "openssl is keg-only, which means it was
# not symlinked into /usr/local, because Apple has deprecated use of
# OpenSSL in favor of its own TLS and crypto libraries."
brew install openssl
# Symlink those versions into /usr/local/lib, which gets Python to dynamically
# link against those instead of the version in /usr/lib/.
# Got the idea from https://forums.developer.apple.com/thread/119429
cd /usr/local/lib
sudo ln -s /usr/local/Cellar/openssl/1.0.2t/lib/libssl.1.0.0.dylib libssl.dylib
sudo ln -s /usr/local/Cellar/openssl/1.0.2t/lib/libcrypto.1.0.0.dylib libcrypto.dylib

My situation for context:

  • Recently upgraded to MacOS 10.15
  • I use python/pip installed via homebrew: brew install python
  • pip3 was failing with SIGABRT

Header of system error report:

Process:               Python [52429]
Path:                  /usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python
Identifier:            Python
Version:               3.7.4 (3.7.4)
Code Type:             X86-64 (Native)
Parent Process:        zsh [43309]
Responsible:           iTerm2 [2316]
User ID:               501

Date/Time:             2019-10-09 09:52:18.148 -0700
OS Version:            Mac OS X 10.15 (19A583)
Report Version:        12
Bridge OS Version:     4.0 (17P572)
Anonymous UUID:        

Sleep/Wake UUID:       

Time Awake Since Boot: 9900 seconds
Time Since Wake:       7300 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

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.


回答3:

r.xuan from this Apple Dev thread identified the steps of a workaround for the error Invalid dylib load. Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI. by replacing the libssl.dylib and libcrypto.dylib links in /usr/local/lib with links to libs from Homebrew's install of openssl.

The steps are:

Get fresh libs

1) brew update && brew upgrade && brew install openssl

2) cd /usr/local/Cellar/openssl/1.0.2t/lib

3) sudo cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib /usr/local/lib/

Backup the old ones

4) cd /usr/local/lib

5) mv libssl.dylib libssl_bak.dylib

6) mv libcrypto.dylib libcrypto_bak.dylib

Create new links

7) sudo ln -s libssl.1.0.0.dylib libssl.dylib

8) sudo ln -s libcrypto.1.0.0.dylib libcrypto.dylib



回答4:

I prefer a combination of @bixel, @Juro Oravec & @honkaboy answers:

brew install openssl
cd /usr/local/lib
sudo ln -s /usr/local/opt/openssl/lib/libssl.dylib libssl.dylib
sudo ln -s /usr/local/opt/openssl/lib/libcrypto.dylib libcrypto.dylib

This way, at least in theory, when updating openssl the dylibs will always point to the latest versions. /usr/local/opt/openssl is actually a link to /usr/local/Cellar/openssl/Cellar/openssl/1.0.2t (the version of openssl installed by brew).

The reason the issue happens is actually explained by brew:

openssl is keg-only, which means it was not symlinked into /usr/local, because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

Trying to run brew link openssl:

Warning: Refusing to link macOS-provided software: openssl If you need to have openssl first in your PATH run: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find openssl you may need to set: export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/usr/local/opt/openssl/include"

For pkg-config to find openssl you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"

So, basically you need to link them manually.



回答5:

For me it was enough to re-install Python's cryptography package.

pip uninstall cryptography
pip install cryptography


回答6:

It must be usage of some dependencies like cryptography

Solution:

cd your-site-packages-path/
vim ./asn1crypto/_int.py

find this line; delete it, and everything is ok

# from ._perf._big_num_ctypes import libcrypto

Here is my problem

Process:               Python [85179]
Path:                  /usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python
Identifier:            Python
Version:               3.7.4 (3.7.4)
Code Type:             X86-64 (Native)
Parent Process:        ??? [85161]
Responsible:           iTerm2 [11711]
User ID:               501

Date/Time:             2019-10-07 23:00:25.143 +0800
OS Version:            Mac OS X 10.15 (19A582a)
Report Version:        12
Bridge OS Version:     3.0 (14Y906)
Anonymous UUID:        32C73ADD-1291-FA0E-DC02-48D539674325


Time Awake Since Boot: 42000 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

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.


回答7:

I was seeing similar problems with ansible. The culprit was asn1crypto, and the problem has been already fixed.

My solution was to manually remove it and reinstall it with pip:

  1. rm -r /usr/local/lib/python2.7/site-packages/asn1crypto*. This allowed pip to work without problems.
  2. pip install asn1crypto, which installed 1.2.0:
  Found existing installation: asn1crypto 0.24.0
    Uninstalling asn1crypto-0.24.0:
      Successfully uninstalled asn1crypto-0.24.0
Successfully installed asn1crypto-1.2.0

NOTE: You can check if asn1crypto is the culprit by running python in verbose mode, e.g. python -v $(which ansible). In my case it crashed while doing some asn1crypto related imports:

# /usr/local/lib/python2.7/site-packages/asn1crypto/_perf/_big_num_ctypes.pyc matches /usr/local/lib/python2.7/site-packages/asn1crypto/_perf/_big_num_ctypes.py
import asn1crypto._perf._big_num_ctypes # precompiled from /usr/local/lib/python2.7/site-packages/asn1crypto/_perf/_big_num_ctypes.pyc
[1]    59247 abort      python -v $(which ansible)

Related: https://github.com/Homebrew/homebrew-core/issues/44996



回答8:

If you're using Kevlar from DevMate, upgrade to 4.3.1, which "Fixed macOS Catalina crash caused by version of libcrypto.dylib".



回答9:

Looks like it was a Homebrew issue. I did brew reinstall python3 and it worked.



回答10:

Try:

python3 -m pip install oscrypto

Worked for me!