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后,服务正常运行。

相关推荐
多米Domi01118 分钟前
0x3f 第49天 面向实习的八股背诵第六天 过了一遍JVM的知识点,看了相关视频讲解JVM内存,垃圾清理,买了plus,稍微看了点确定一下方向
jvm·数据结构·python·算法·leetcode
人工智能训练6 小时前
【极速部署】Ubuntu24.04+CUDA13.0 玩转 VLLM 0.15.0:预编译 Wheel 包 GPU 版安装全攻略
运维·前端·人工智能·python·ai编程·cuda·vllm
yaoming1686 小时前
python性能优化方案研究
python·性能优化
码云数智-大飞7 小时前
使用 Python 高效提取 PDF 中的表格数据并导出为 TXT 或 Excel
python
biuyyyxxx8 小时前
Python自动化办公学习笔记(一) 工具安装&教程
笔记·python·学习·自动化
极客数模8 小时前
【2026美赛赛题初步翻译F题】2026_ICM_Problem_F
大数据·c语言·python·数学建模·matlab
小鸡吃米…10 小时前
机器学习中的代价函数
人工智能·python·机器学习
Li emily11 小时前
如何通过外汇API平台快速实现实时数据接入?
开发语言·python·api·fastapi·美股
m0_5613596711 小时前
掌握Python魔法方法(Magic Methods)
jvm·数据库·python
Ulyanov11 小时前
顶层设计——单脉冲雷达仿真器的灵魂蓝图
python·算法·pyside·仿真系统·单脉冲