You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行pip install paramiko时bcrypt编译失败求助

解决macOS下pip安装paramiko/pysftp时bcrypt编译失败问题

问题描述

执行pip install paramiko或pip install pysftp时,因bcrypt编译失败导致安装终止,错误信息如下:

=============================DEBUG ASSISTANCE=============================
      If you are seeing a compilation error please try the following steps to
      successfully install bcrypt:
      1) Upgrade to the latest pip and try again. This will fix errors for most
         users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
      2) Ensure you have a recent Rust toolchain installed. bcrypt requires
         rustc >= 1.64.0. (1.63 may be used by setting the BCRYPT_ALLOW_RUST_163
         environment variable)
      
      Python: 3.9.7
      platform: macOS-10.16-x86_64-i386-64bit
      pip: n/a
      setuptools: 69.0.2
      setuptools_rust: 1.8.1
      rustc: 1.74.0 (79e9716c9 2023-11-13)
      =============================DEBUG ASSISTANCE=============================
      
  error: `cargo rustc --lib --message-format=json-render-diagnostics --manifest-path src/_bcrypt/Cargo.toml --release -v --features pyo3/extension-module --crate-type cdylib -- -C 'link-args=-undefined dynamic_lookup -Wl,-install_name,@rpath/_bcrypt.abi3.so'` failed with code 101
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for bcrypt
Failed to build bcrypt
ERROR: Could not build wheels for bcrypt, which is required to install pyproject.toml-based projects

已尝试升级pip、安装rust工具链,但问题依旧。

解决方案

1. 修复pip关联并升级

错误中显示pip: n/a,说明当前环境pip未正确关联到Python3.9。执行以下命令确保pip正常:

python3 -m pip install --upgrade pip setuptools wheel

2. 安装Xcode命令行工具

macOS编译依赖Xcode命令行工具,执行:

xcode-select --install

若已安装仍报错,重置工具链:

xcode-select --reset

3. 安装预编译的bcrypt二进制包

跳过编译步骤,直接安装官方预编译的轮子:

python3 -m pip install bcrypt --only-binary :all:

安装完成后再尝试安装paramiko/pysftp:

python3 -m pip install paramiko

4. 指定架构编译

针对macOS x86_64架构设置环境变量后再编译:

export ARCHFLAGS="-arch x86_64"
python3 -m pip install paramiko

5. 重置rust工具链

确认rust工具链配置正确,执行:

rustup update
rustup default stable

检查rustc路径:

which rustc

确保输出路径正确,再重新执行安装命令。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.05 04:09:59