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

Mac M1芯片pip安装Python依赖fastrank报错解决方案

M1芯片Mac安装fastrank依赖报错解决

问题现象

通过pip安装Python依赖fastrank时,Intel芯片Mac可正常完成安装,M1芯片Mac安装失败,已尝试使用Rosetta终端运行安装命令、安装多款疑似相关组件,均未解决问题。完整报错如下:

***Collecting fastrank
  Using cached fastrank-0.7.0.tar.gz (52 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [27 lines of output]
      ⚠️  Warning: Please use maturin in pyproject.toml with a version constraint, e.g. `requires = ["maturin>=0.12,<0.13"]`. This will become an error.
      💥 maturin failed
        Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
        Caused by: `cargo metadata` exited with an error:     Updating crates.io index
      warning: spurious network error (2 tries remaining): http parser error: stream ended at an unexpected time; class=Http (34)
      warning: spurious network error (1 tries remaining): http parser error: stream ended at an unexpected time; class=Http (34)
      error: failed to get `bzip2` as a dependency of package `fastrank v0.7.0 (/private/var/folders/5l/sppq3g8556nffpc74l_54zv40000gn/T/pip-install-ugbpj9al/fastrank_b60c765ae0df4f76b49d90ab4a21f9f2)`
      
      Caused by:
        failed to load source for dependency `bzip2`
      
      Caused by:
        Unable to update registry `crates-io`
      
      Caused by:
        failed to fetch `https://github.com/rust-lang/crates.io-index`
      
      Caused by:
        network failure seems to have happened
        if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
        https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
      
      Caused by:
        http parser error: stream ended at an unexpected time; class=Http (34)
      Error running maturin: Command '['maturin', 'pep517', 'write-dist-info', '--metadata-directory', '/private/var/folders/5l/sppq3g8556nffpc74l_54zv40000gn/T/pip-modern-metadata-hdyh51_d', '--interpreter', '/Users/chinwekele/.pyenv/versions/3.7.13/bin/python3']' returned non-zero exit status 1.
      Checking for Rust toolchain....
      Running `maturin pep517 write-dist-info --metadata-directory /private/var/folders/5l/sppq3g8556nffpc74l_54zv40000gn/T/pip-modern-metadata-hdyh51_d --interpreter /Users/chinwekele/.pyenv/versions/3.7.13/bin/python3`
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

报错根因

该报错和M1芯片架构无直接关联。fastrank基于Rust开发,安装时需要通过Rust包管理器Cargo拉取上游依赖,默认Cargo源访问不稳定导致拉取中断,触发元数据生成失败。Intel设备安装成功是因为对应网络环境可正常访问Cargo源,和芯片架构无关。

解决步骤

按顺序执行以下操作即可完成安装:

  • 配置Cargo国内镜像源,同时开启Git客户端拉取模式提升拉取稳定性。首先执行命令创建Cargo配置文件目录:
    mkdir -p ~/.cargo
    编辑~/.cargo/config.toml文件,写入以下配置:
    [source.crates-io]
    replace-with = 'mirror'
    [source.mirror]
    registry = "https://rsproxy.cn/crates.io-index"
    [registries.mirror]
    index = "https://rsproxy.cn/crates.io-index"
    [net]
    git-fetch-with-cli = true
    
  • 校验本地Rust工具链架构:执行rustup show查看输出中host字段值,若显示为x86_64-apple-darwin,说明当前安装的是x86版本Rust,卸载后重新安装arm64版本Rust即可,正确的host值应为aarch64-apple-darwin。
  • 安装系统层面的bzip2依赖,避免编译阶段找不到依赖库:
    brew install bzip2
  • 清理pip历史缓存,无缓存重新安装包:
    pip cache purge && pip install fastrank --no-cache-dir

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.27 12:42:06