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

M1 Mac安装TensorFlow时wrapt编译失败及conda通道问题求助

M1 Mac Miniforge3环境TensorFlow安装问题解决指南

一、先修复conda通道异常

  1. 强制重置conda通道配置,解决无法移除conda-forge、更新失败的问题:

    • 执行命令:conda config --remove-key channels
    • 重新添加默认通道:conda config --add channels defaults
    • 设置通道严格优先级:conda config --set channel_priority strict
    • 测试更新:conda update --all
  2. 若上述操作无效,直接删除配置文件重建:

    • 删除配置文件:rm ~/.condarc
    • 重新初始化conda:conda init zsh(使用bash则替换为conda init bash)

二、最稳妥的M1适配TensorFlow安装方案(避开编译坑)

Python3.11在M1平台上的wrapt编译兼容性尚未完全成熟,建议切换到Python3.10环境走官方适配路线:

  1. 创建干净的conda环境:
    • conda create -n tf_env python=3.10
    • 激活环境:conda activate tf_env
  2. 添加苹果官方适配通道:
    • conda config --add channels apple
    • conda config --add channels conda-forge
  3. 按顺序安装依赖与TensorFlow:
    • conda install -c apple tensorflow-deps
    • pip install tensorflow-macos
    • pip install tensorflow-metal(启用M1 GPU加速)

三、坚持用Python3.11的临时解决办法

  1. 查看当前Python的平台标签:python -c "import sysconfig; print(sysconfig.get_platform())"
  2. 下载对应版本的wrapt预编译wheel包(例如wrapt-1.15.0-cp311-cp311-macosx_11_0_arm64.whl)
  3. 本地安装该wheel包:pip install /你下载的wheel文件路径/wrapt-xxx.whl
  4. 再执行TensorFlow安装:pip install tensorflow-macos

四、验证安装结果

激活环境后运行以下代码:

import tensorflow as tf
print(tf.__version__)
print(tf.config.list_physical_devices('GPU'))

能正常输出版本号和GPU设备信息,即为安装成功。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 18:12:47