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会自动管理预编译依赖,避免源码编译步骤:- 创建并激活专属环境:
conda create -n tf_env python=3.10 conda activate tf_env - 安装TensorFlow:
conda install tensorflow
- 创建并激活专属环境:
指定匹配版本的grpcio
TensorFlow对grpcio有版本要求,先安装对应版本的预编译包再装TensorFlow:pip3 install grpcio==1.54.0 # 适配TensorFlow 2.15及以上版本 pip3 install tensorflow
内容的提问来源于stack exchange,提问作者EleniSop
相关产品推荐
相关产品推荐

