You need to enable JavaScript to run this app. Google Colab运行EQTransformer报tensorflow_core.compat.v2无__internal__属性错误
优惠活动
大模型
产品
解决方案
定价
更多

Google Colab运行EQTransformer报tensorflow_core.compat.v2无__internal__属性错误

问题解决步骤

你遇到的报错是Google Colab预装的包版本更新后,与EQTransformer 0.1.59依赖的旧版本TensorFlow生态包产生了版本冲突,按以下步骤操作即可修复:

  • 第一步:运行代码前先卸载Colab预装的所有冲突依赖,执行以下命令:
!pip uninstall -y tensorflow tensorflow-probability keras gast h5py
  • 第二步:安装完全匹配EQTransformer要求的依赖版本,注意要先安装匹配的tensorflow-probability 0.8.0(该版本适配gast 0.2.2与TensorFlow 2.0.0,你之前装的0.9.0版本仍然存在版本适配问题),再安装EQTransformer:
!pip install tensorflow==2.0.0 tensorflow-probability==0.8.0 gast==0.2.2 keras==2.3.1 h5py==2.10.0
!pip install EQTransformer==0.1.59
  • 第三步:在你所有业务代码的最开头加入以下两行,主动禁用TensorFlow v2的默认行为,避免API调用冲突,即可解决AttributeError: module 'tensorflow_core.compat.v2' has no attribute '__internal__'报错:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

每次重新打开Colab实例或者重置运行时后,都需要先执行前两步的卸载重装命令,Colab的运行时环境为临时环境,关闭后会重置为默认预装版本。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.18 19:54:03