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

Macbook+VSCode环境下TensorFlow安装卡顿在grpcio编译环节求助

解决Macbook上pip安装TensorFlow卡在grpcio编译环节的问题

卡在Building wheel for grpcio (setup.py) ... /是因为pip默认会从源码编译grpcio,Mac环境下这个过程耗时极长,甚至可能失败。针对你的Python 3.10.9、pip 23.3.1环境,试试以下方案:

  • 优先安装预编译的grpcio包
    强制pip使用预编译的wheel包,跳过源码编译:

    pip3 install grpcio --only-binary :all:
    

    完成后再执行pip3 install tensorflow,此时不会再卡在grpcio编译环节。

  • 升级编译工具链
    旧版的setuptools或wheel可能导致编译效率低下,先升级工具:

    pip3 install --upgrade setuptools wheel
    

    升级后重新尝试安装TensorFlow。

  • 用Conda替代pip安装
    Conda会自动管理预编译依赖,避免源码编译步骤:

    1. 创建并激活专属环境:
      conda create -n tf_env python=3.10
      conda activate tf_env
      
    2. 安装TensorFlow:
      conda install tensorflow
      
  • 指定匹配版本的grpcio
    TensorFlow对grpcio有版本要求,先安装对应版本的预编译包再装TensorFlow:

    pip3 install grpcio==1.54.0  # 适配TensorFlow 2.15及以上版本
    pip3 install tensorflow
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.14 17:44:54