Python crashing on MacOS 10.15 Beta (19A582a) with “/usr/lib/libcrypto.dylib”

前端 未结 13 523
星月不相逢
星月不相逢 2020-12-12 15:47

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

相关标签:
13条回答
  • 2020-12-12 16:01

    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.

    0 讨论(0)
  • 2020-12-12 16:09

    Use the following steps to solve:

    • brew update && brew upgrade && brew reinstall openssl
    • cd /usr/local/Cellar/openssl@1.1/1.1.1g/lib
    • sudo cp libssl.1.1.1.dylib libcrypto.1.1.1.dylib /usr/local/lib/
    • sudo ln -s libssl.1.0.0.dylib libssl.dylib
    • sudo ln -s libcrypto.1.0.0.dylib libcrypto.dylib`
    0 讨论(0)
  • 2020-12-12 16:10

    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.
    
    0 讨论(0)
  • 2020-12-12 16:14

    I met the same issue when I was using ctypes.cdll to open /usr/lib/libcrypto.dylib with Python 3.7. However the dylib COULD be opened with Python 2.7.

    I installed the latest openssl with brew install, then set the environment variables and created links as what they suggested above, NOTHING good was happened.

    After several hours' digging, I found a workaround solution.

    I found some libcrypto.X.dylib in /usr as following,

    /usr/lib/libcrypto.dylib
    /usr/lib/libcrypto.0.9.7.dylib
    /usr/lib/libcrypto.0.9.8.dylib
    /usr/lib/libcrypto.35.dylib
    /usr/lib/libcrypto.41.dylib
    /usr/lib/libcrypto.42.dylib
    /usr/lib/libcrypto.44.dylib
    
    /usr/local/opt/openssl/lib/libcrypto.1.1.dylib
    /usr/local/opt/openssl/lib/libcrypto.dylib
    

    Firstly, I used the followed one to replace that in /usr/lib instead.

    os.environ['DYLD_FALLBACK_LIBRARY_PATH'] = '/usr/local/opt/openssl/lib'
    

    It could be loaded but some apis were missing,

    AttributeError: dlsym(0x..., ECDH_OpenSSL): symbol not found
    

    I created a link for /usr/lib/libcrypto.X.dylib in my script path.

    ln -s /usr/lib/libcrypto.X.dylib lib/libcrypto.dylib
    

    Then add the path to DYLD_FALLBACK_LIBRARY_PATH

    os.environ['DYLD_FALLBACK_LIBRARY_PATH'] = 'lib' # It should be a absolute path
    

    At last, it worked.

    0 讨论(0)
  • 2020-12-12 16:17

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

    pip uninstall cryptography
    pip install cryptography
    
    0 讨论(0)
  • 2020-12-12 16:17

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

    0 讨论(0)
提交回复
热议问题