You need to enable JavaScript to run this app. Apple M1 Mac无需Rosetta模式安装cryptography的编译报错解决
优惠活动
大模型
产品
解决方案
定价
更多

Apple M1 Mac无需Rosetta模式安装cryptography的编译报错解决

M1 原生无Rosetta模式安装cryptography 操作指南

报错本质

报错核心是arm64架构下pip拉取的旧版cffi、libffi依赖为x86_64编译产物,动态加载时找不到对应架构的_ffi_prep_closure符号,该问题在早期公开方案中未配套处理libffi架构匹配问题,因此无法通过基础pip升级解决。

前置依赖配置

  • 通过Homebrew安装arm64原生编译依赖:
    brew install openssl@1.1 rust cffi libffi pkg-config
  • 在~/.zshrc末尾追加库路径配置,确保编译时优先匹配Homebrew安装的arm64版本库:
    export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib -L/opt/homebrew/opt/libffi/lib"
    export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/libffi/include"
    export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@1.1/lib/pkgconfig:/opt/homebrew/opt/libffi/lib/pkgconfig"
    
  • 执行source ~/.zshrc让环境变量立即生效

安装前环境清理

  • 清空pip缓存,避免残留旧架构的编译产物:
    pip cache purge
  • 升级构建工具到最新兼容版本:
    python3 -m pip install --upgrade pip setuptools wheel

正式安装

  • 强制使用本地系统依赖编译arm64版本的cryptography,避免pip自动拉取不匹配的预编译包:
    pip install cryptography --no-binary cryptography

内容的提问来源于stack exchange,提问作者Joe Fedorowicz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.11.05 12:24:02