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

在Mac M1/M2芯片上安装R包r-text时出现tokenizers构建失败错误

Mac M1/M2芯片R环境安装r-text包:解决tokenizers构建失败问题

执行textrpp_install()时出现以下报错:

Failed to build tokenizers
ERROR: Could not build wheels for tokenizers, which is required to install pyproject.toml-based projects

按以下步骤解决:

  • 安装Xcode命令行工具(编译依赖)
    在终端执行:

    xcode-select --install
    

    若已安装,会提示无需操作。

  • 安装Rust环境(tokenizers编译依赖)
    用Homebrew安装Rust:

    brew install rust
    

    配置环境变量(根据你的shell类型选择):

    • zsh用户:
      echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.zshrc
      source ~/.zshrc
      
    • bash用户:
      echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bash_profile
      source ~/.bash_profile
      
  • 确保Python为ARM64架构版本
    M1/M2需使用适配arm64的Python(如Homebrew安装的版本),避免用系统自带的x86版本。终端执行arch验证架构为arm64,python3 --version确认Python版本,若为x86版本,重新用Homebrew安装Python:

    brew install python
    
  • 在R中重新安装
    先手动安装Python版tokenizers:

    reticulate::py_install("tokenizers", pip = TRUE)
    

    再执行:

    textrpp_install()
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.31 00:21:26