Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python在MacOS 10.15测试版(19A582a)上崩溃,带有/usr/lib/libcrypto.dylib“;_Python_Oh My Zsh_Libcrypto_Macos Catalina - Fatal编程技术网

Python在MacOS 10.15测试版(19A582a)上崩溃,带有/usr/lib/libcrypto.dylib“;

Python在MacOS 10.15测试版(19A582a)上崩溃,带有/usr/lib/libcrypto.dylib“;,python,oh-my-zsh,libcrypto,macos-catalina,Python,Oh My Zsh,Libcrypto,Macos Catalina,我用新的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:

我用新的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.


它必须使用一些依赖项,如加密

解决方案:

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.

警告:我不是安全专家,这个解决方案会弄乱加密库

我不认为你的问题源于zsh或者我的zsh。我的猜测是:MacOS 10.15安装的一些加密库与自制的
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安装python
  • brew install openssl
    
  • 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.
确定了错误解决方法的步骤
动态库加载无效。客户端不应加载未版本的libcrypto动态库,因为它没有稳定的ABI。
通过将
/usr/local/lib
中的
libssl.dylib
libcrypto.dylib
链接替换为Homebrew安装的
openssl
中的libs链接

这些步骤是: 获取新的LIB

1)
brew更新、brew升级和brew安装openssl

2)
cd/usr/local/ceral/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
我刚刚遇到了同样的问题,手动链接起来有点不舒服

我能简单地解决这个问题

  • 通过自制安装openssl:
    brew install openssl
    
  • 通过DYLD_LIBRARY_路径指向openssl中的动态库:
    export DYLD_LIBRARY_PATH=/usr/local/opt/openssl/lib:$DYLD_LIBRARY_PATH
    
  • 我刚刚在.zshrc中添加了这一行

    编辑:根据,使用
    DYLD\u FALLBACK\u LIBRARY\u PATH
    可能优于
    DYLD\u LIBRARY\u PATH


    编辑2:正如下面的评论中提到的,应该是公认的答案。只需重新安装
    加密软件包。

    我更喜欢@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时,dylibs将始终指向最新版本
    /usr/local/opt/openssl
    实际上是指向
    /usr/local/ceral/openssl/ceral/openssl/1.0.2t
    (brew安装的openssl版本)的链接

    brew实际上解释了问题发生的原因:

    openssl只是keg,这意味着它没有符号链接到/usr/local, 因为苹果不赞成使用OpenSSL,而是支持自己的TLS和加密库

    正在尝试运行
    brew链接openssl

    警告:拒绝链接macOS提供的软件:openssl(如果需要) 要让openssl首先在路径中运行:echo“export” PATH=“/usr/local/opt/openssl/bin:$PATH”>>~/.bash\u profile

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

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


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

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

    我的解决方案是手动删除它,然后用
    pip
    重新安装它:

  • rm-r/usr/local/lib/python2.7/site-packages/asn1crypto*
    。这使得
    pip
    可以正常工作
  • pip安装asn1crypto
    ,它安装了
    1.2.0
  • 注意:您可以通过在详细模式下运行
    python
    来检查
    asn1crypto
    是否是罪魁祸首,例如
    python-v$(哪个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)
    

    相关:

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

    看起来这是一个自制问题。我确实
    brew重新安装了python3
    ,它成功了。

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

    pip uninstall cryptography
    pip install cryptography
    
    尝试:


    为我工作

    要遵循上述答案,希望链接libssl.dylib文件,但未找到以下位置:

    /usr/local/Cellar/openssl/1.0.2t/lib/
    
    然而,@bixel接受的答案在下面的位置找到了该文件

    /usr/local/opt/openssl/lib
    

    这对我很有效

    我在使用
    ctypes.cdll
    Python3.7
    打开
    /usr/lib/libcrypto.dylib
    时遇到了同样的问题。然而,
    dylib
    可以用
    python2.7
    打开

    我用
    brew install
    安装了最新的
    openssl
    ,然后按照上面的建议设置了环境变量并创建了链接,但没有发生什么好事

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

    我在
    /usr
    中找到了一些
    libcrypto.X.dylib
    ,如下所示:

    /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
    
    我为AttributeError: dlsym(0x..., ECDH_OpenSSL): symbol not found
    ln -s /usr/lib/libcrypto.X.dylib lib/libcrypto.dylib
    
    os.environ['DYLD_FALLBACK_LIBRARY_PATH'] = 'lib' # It should be a absolute path
    
    import sys
    from ctypes.util import find_library
    from ctypes import CDLL
    
    name = sys.argv[1]
    path = find_library(name)
    print(f"path: {path}")
    lib = CDLL(path)
    
    $ sw_vers
    ProductName:    Mac OS X
    ProductVersion: 10.15.7
    BuildVersion:   19H15
    $ /usr/bin/python3 --version
    Python 3.8.2
    $ ls -al /usr/lib/ | grep 'libcrypto\|libssl'
    .rwxr-xr-x 1.1M root 22 Sep  8:29 libcrypto.0.9.7.dylib
    .rwxr-xr-x 1.4M root 22 Sep  8:29 libcrypto.0.9.8.dylib
    .rwxr-xr-x 1.5M root 22 Sep  8:29 libcrypto.35.dylib
    .rwxr-xr-x 1.5M root 22 Sep  8:29 libcrypto.41.dylib
    .rwxr-xr-x 1.5M root 22 Sep  8:29 libcrypto.42.dylib
    .rwxr-xr-x 1.5M root 22 Sep  8:29 libcrypto.44.dylib
    .rwxr-xr-x  32k root 22 Sep  8:29 libcrypto.dylib
    .rwxr-xr-x 212k root 22 Sep  8:29 libssl.0.9.7.dylib
    .rwxr-xr-x 335k root 22 Sep  8:30 libssl.0.9.8.dylib
    .rwxr-xr-x 330k root 22 Sep  8:28 libssl.35.dylib
    .rwxr-xr-x 313k root 22 Sep  8:29 libssl.43.dylib
    .rwxr-xr-x 300k root 22 Sep  8:29 libssl.44.dylib
    .rwxr-xr-x 294k root 22 Sep  8:29 libssl.46.dylib
    .rwxr-xr-x  32k root 22 Sep  8:29 libssl.dylib
    $ /usr/bin/python3 openlib.py libcrypto
    path: /usr/lib/libcrypto.dylib
    Abort trap: 6
    $ /usr/bin/python3 openlib.py libcrypto.35
    path: /usr/lib/libcrypto.35.dylib
    $ /usr/bin/python3 openlib.py libcrypto.44
    path: /usr/lib/libcrypto.44.dylib
    
    Process:               Python [97291]
    Path:                  /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python
    Identifier:            Python
    Version:               3.8.2 (3.8.2)
    Build Info:            python3-73040006000000~117
    Code Type:             X86-64 (Native)
    Parent Process:        bash [84388]
    Responsible:           iTerm2 [7705]
    User ID:               501
    
    Date/Time:             2020-12-26 00:28:00.281 +0800
    OS Version:            Mac OS X 10.15.7 (19H15)
    Report Version:        12
    Anonymous UUID:        1C43F3DB-1783-4B94-B663-7F7E8D331B56
    
    
    Time Awake Since Boot: 53000 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.
    
    Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
    0   libsystem_kernel.dylib          0x00007fff69bba33a __pthread_kill + 10
    1   libsystem_pthread.dylib         0x00007fff69c76e60 pthread_kill + 430
    2   libsystem_c.dylib               0x00007fff69b41808 abort + 120
    3   libcrypto.dylib                 0x00007fff6766b7e4 __report_load + 415
    
    DEFAULT_LIBRARY_FALLBACK = [
        os.path.expanduser("~/lib"),
        "/usr/local/lib",
        "/lib",
        "/usr/lib",
    ]
    
    $ /usr/bin/python3
    Python 3.8.2 (default, Nov  4 2020, 21:23:28)
    [Clang 12.0.0 (clang-1200.0.32.28)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from ctypes.util import find_library
    >>> find_library('libcrypto')
    '/usr/lib/libcrypto.dylib'
    >>>
    
    $ pwd
    /Users/gasolwu
    $ ln -s /usr/lib/libcrypto.44.dylib $HOME/lib/libcrypto.dylib
    $ $ ls ~/lib
    libcrypto.dylib
    
    $ /usr/bin/python3 openlib.py libcrypto
    path: /Users/gasolwu/lib/libcrypto.dylib
    
    export DYLD_LIBRARY_PATH=/usr/local/opt/openssl/lib:$DYLD_LIBRARY_PATH