MacOS 使用ssh2-python报错ImportError: dlopen ... Library not loaded

环境

  • Apple M3 Pro
  • MacOS 14.1
  • Python 3.9
  • ssh2-python==0.26.0

报错信息

  File "/Users/skyler/Documents/py-env/venv3.9/lib/python3.9/site-packages/pssh/clients/__init__.py", line 19, in <module>
    from .native.parallel import ParallelSSHClient
  File "/Users/skyler/Documents/py-env/venv3.9/lib/python3.9/site-packages/pssh/clients/native/__init__.py", line 19, in <module>
    from .parallel import ParallelSSHClient
  File "/Users/skyler/Documents/py-env/venv3.9/lib/python3.9/site-packages/pssh/clients/native/parallel.py", line 20, in <module>
    from .single import SSHClient
  File "/Users/skyler/Documents/py-env/venv3.9/lib/python3.9/site-packages/pssh/clients/native/single.py", line 24, in <module>
    from ssh2.error_codes import LIBSSH2_ERROR_EAGAIN
ImportError: dlopen(/Users/skyler/Documents/py-env/venv3.9/lib/python3.9/site-packages/ssh2/error_codes.cpython-39-darwin.so, 0x0002): Library not loaded: /private/var/folders/90/2z2_gp3s4z737mq6fyxsw6g80000gn/T/pip-install-1gzz284h/ssh2-python/src/src/libssh2.1.dylib
  Referenced from: <F8048C8C-1214-3A6C-A790-0DEAB6514422> /Users/skyler/Documents/py-env/venv3.9/lib/python3.9/site-packages/ssh2/error_codes.cpython-39-darwin.so
  Reason: tried: '/private/var/folders/90/2z2_gp3s4z737mq6fyxsw6g80000gn/T/pip-install-1gzz284h/ssh2-python/src/src/libssh2.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/private/var/folders/90/2z2_gp3s4z737mq6fyxsw6g80000gn/T/pip-install-1gzz284h/ssh2-python/src/src/libssh2.1.dylib' (no such file), '/private/var/folders/90/2z2_gp3s4z737mq6fyxsw6g80000gn/T/pip-install-1gzz284h/ssh2-python/src/src/libssh2.1.dylib' (no such file)

解决方式

brew install libssh2
  
export DYLD_LIBRARY_PATH="$(brew --prefix libssh2)/lib:${DYLD_LIBRARY_PATH}"

安装完依赖的lib后,服务正常运行。

相关推荐
fanstuck3 分钟前
2025MCM美国大学生数学建模竞赛B题-可持续旅游管理思路详解+建模论文+源代码
人工智能·python·数学建模·数据挖掘·美赛
LuiChun13 分钟前
Django-Admin WebView 集成项目技术规范文档 v2.1
后端·python·django
我是唐青枫16 分钟前
Mac 上如何同时运行多个MySQL版本?
mysql·macos·adb
imoisture1 小时前
PyTorch中的movedim、transpose与permute
人工智能·pytorch·python·深度学习
Tester_孙大壮1 小时前
第31章 测试驱动开发中的设计模式与重构解析(Python 版)
python·设计模式·重构
weixin_307779131 小时前
C++和Python实现SQL Server数据库导出数据到S3并导入Redshift数据仓库
数据库·c++·数据仓库·python·sqlserver
笛柳戏初雪1 小时前
Python中容器类型的数据(上)
开发语言·python
清弦墨客1 小时前
【蓝桥杯】43695.填字母游戏
python·蓝桥杯·编程算法
好悬给我拽开线2 小时前
【论文阅读】RT-SKETCH: GOAL-CONDITIONED IMITATION LEARNING FROM HAND-DRAWN SKETCHES
论文阅读·macos·sketch
查理零世2 小时前
保姆级讲解 python之zip()方法实现矩阵行列转置
python·算法·矩阵