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

相关推荐
言之。20 分钟前
Andrej Karpathy 演讲【PyTorch at Tesla】
人工智能·pytorch·python
赵谨言29 分钟前
基于Python楼王争霸劳动竞赛数据处理分析
大数据·开发语言·经验分享·python
夕秋一梦31 分钟前
mac 安装 dmg 格式程序,打开显示已损坏问题
macos
智启七月1 小时前
谷歌 Gemini 3.0 正式发布:一键生成 Web OS,编程能力碾压竞品
人工智能·python
2401_841495641 小时前
【强化学习】动态规划算法
人工智能·python·算法·动态规划·强化学习·策略迭代·价值迭代
测试19981 小时前
自动化测试报告生成(Allure)
自动化测试·软件测试·python·selenium·测试工具·职场和发展·测试用例
DKunYu2 小时前
PyTorch入门
人工智能·pytorch·python·深度学习
ZhengEnCi2 小时前
Python_哈希表完全指南-从字典到高效查找的 Python 编程利器
python
今天没ID2 小时前
Python 集合类型全解析:从网球赛事案例看透字符串、列表、元组、集合与字典(1)
python
小宁爱Python2 小时前
从零搭建 RAG 智能问答系统 4:从多模态架构到 Milvus 向量存储实践
python·milvus