使用“ /usr/lib/libcrypto.dylib”的MacOS 10.15 Beta(19A582a)上的Python崩溃


47

我使用新的macOS Catalina运行了Django项目,并且运行良好。
我安装了oh_my_zsh,然后尝试运行它因以下错误而崩溃的同一项目。我卸载了oh_my_zsh并再次尝试,但没有成功。

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.

如果您在virtualenv中:对我来说,对venv进行了(完整)重置(删除并重新创建了所有依赖项等)
basti

Answers:


94

我只是遇到了同样的问题,手动链接周围的东西有点不舒服。

我能够通过简单地解决问题

  1. 通过自制软件安装openssl:
    brew install openssl
  2. 通过DYLD_LIBRARY_PATH从openssl指向动态库:
    export DYLD_LIBRARY_PATH=/usr/local/opt/openssl/lib:$DYLD_LIBRARY_PATH

我刚刚将该行添加到我的.zshrc中。

编辑:根据这个问题,的使用DYLD_FALLBACK_LIBRARY_PATH可能比更好DYLD_LIBRARY_PATH

编辑2:如下面的评论中所述,可能是公认的答案。只需重新安装该cryptography软件包。


19
反对不搞乱系统的
投票

这在命令行中也对我有用,但是不适用于脚本。可能会缺少一些东西吗?
ErnestoE

2
可以export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/opt/openssl/lib按照您的描述确认作品。谢谢你的提示!
Luke Hoersten '19

1
这对于使事情正常运行非常有用,但不能完全解决问题。我有一些需要使用Python的crontab作业,并且我不需要确保它们都具有此env设置。我喜欢下面的@Andrei解决方案。它会设置与最新的openssl库有关的符号链接,以便将来对其进行升级时,这些链接也将如此。stackoverflow.com/a/58596931/142318
克里斯(Chris)

1
每个人都应该在此之前尝试@tonyStarks答案,它可能对您来说很容易卸载并重新安装
Micheal C Wallas

38

警告:我不是安全专家,该解决方案与加密库混淆!

我认为您的问题不是源于zsh或oh-my-zsh。我的最佳猜测:MacOS 10.15上安装的某些加密库与Homebrew的python3安装不兼容。

这是为我解决问题的原因

# 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

我的情况:

  • 最近升级到MacOS 10.15
  • 我使用通过自制软件安装的python / pip: brew install python
  • pip3 失败了 SIGABRT

系统错误报告的标题:

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.

29

对我来说,重新安装Python的加密软件包就足够了。

pip uninstall cryptography
pip install cryptography

1
它为我工作。在我的情况下,在将virtualenv更新到最新版本后未执行ansible。
hshan

1
有效!谢谢!对我而言,它pip uninstall cryptography不是remove
fzwo

这也为我解决了。谢谢!
andrewdcato

效果很好-谢谢!
Sherm4n

是的,这就是窍门。谢谢!
Steffen Funke

17

我更喜欢@ bixel,@ Juro Oravec和@honkaboy答案的组合:

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

这样,至少在理论上,当更新openssl时,dylib将始终指向最新版本。/usr/local/opt/openssl实际上是一个链接/usr/local/Cellar/openssl/Cellar/openssl/1.0.2t(brew安装的openssl版本)。

这个问题发生的原因实际上是由brew解释的:

openssl是仅桶式的,这意味着它没有符号链接到/ usr / local,因为Apple已弃用OpenSSL而不是使用其自己的TLS和加密库。

尝试运行brew link openssl

警告:拒绝链接macOS提供的软件:openssl如果需要首先在运行PATH中运行openssl:echo'export PATH =“ / usr / local / opt / openssl / bin:$ PATH”'>>〜/ .bash_profile

为了使编译器能够找到openssl,您可能需要设置:export LDFLAGS =“-L / usr / local / opt / openssl / lib” export CPPFLAGS =“-I / usr / local / opt / openssl / include”

为了使pkg-config查找openssl,您可能需要设置:export PKG_CONFIG_PATH =“ / usr / local / opt / openssl / lib / pkgconfig”

因此,基本上,您需要手动链接它们。


15

Apple Dev线程中的r.xuanInvalid dylib load. Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI. 通过将libssl.dyliblibcrypto.dylib链接替换为/usr/local/libHomebrew安装的lib的链接,从而确定了解决该错误的方法的步骤 openssl

这些步骤是:

获取新的库

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/

备份旧的

4) cd /usr/local/lib

5) mv libssl.dylib libssl_bak.dylib

6) mv libcrypto.dylib libcrypto_bak.dylib

建立新连结

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

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


这在Catalina 10.15.4上对我有用,但是我有/usr/local/Cellar/openssl@1.1并使用了等效文件。使用x.1.0.0.dylib文件,pip3仍然崩溃。
Andrew Delos Reyes

4

它一定是加密等依赖项的用法

解:

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

找到这条线; 删除它,一切正常

# from ._perf._big_num_ctypes import libcrypto

这是我的问题

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.

4

我也看到过类似的问题ansible。罪魁祸首是asn1crypto,问题已经解决

我的解决方案是手动将其删除并重新安装pip

  1. rm -r /usr/local/lib/python2.7/site-packages/asn1crypto*。这样可以pip正常工作。
  2. pip install asn1crypto,其中已安装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

注意:您可以asn1crypto通过python以详细模式运行来检查是否是罪魁祸首,例如python -v $(which ansible)。就我而言,它在执行一些asn1crypto相关的导入时崩溃了:

# /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)

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


这是为我工作的那个。我使用的根是格子,使用了ansible。我rm -r执行了答案中列出的命令,然后删除了trellis/.trellis/virtualenv目录中的python环境,然后使用trellis-cli trellis init进行了重新创建python环境并使用pip安装依赖项。
robrecord

这对我
有用

0

如果您使用的是DevMate中的 Kevlar ,请升级到4.3.1,“修复了由libcrypto.dylib版本引起的macOS Catalina崩溃”。


0

看来这是一个自制问题。我做到了brew reinstall python3,它奏效了。



0

要遵循上面提到的答案,想链接libssl.dylib文件,但找不到以下位置:

/usr/local/Cellar/openssl/1.0.2t/lib/

但是,作为@bixel接受的答案,该文件位于以下位置

/usr/local/opt/openssl/lib

它为我工作。


0

我遇到我的时候用的是同一个问题ctypes.cdll,打开/usr/lib/libcrypto.dylibPython 3.7。但是dylib可以用打开Python 2.7

我使用安装了最新版本opensslbrew install,然后按照上面的建议设置环境变量并创建了链接,但是一切都没有发生。

经过几个小时的挖掘,我找到了一种解决方法。

我发现了一些libcrypto.X.dylib/usr如下图所示:

/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

首先,我用后面的代替它/usr/lib

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

可以加载,但是缺少一些api,

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

/usr/lib/libcrypto.X.dylib在脚本路径中创建了的链接。

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

然后将路径添加到 DYLD_FALLBACK_LIBRARY_PATH

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

最后,它成功了。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.