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

Miniconda环境导入tensorflow_hub遇AttributeError问题求助

解决TensorFlow与TensorFlow Estimator版本不兼容导致的AttributeError问题

问题根源

你的环境中TensorFlow 2.4.1和TensorFlow Estimator 2.6.0版本不匹配,高版本的estimator调用了低版本TensorFlow中不存在的内部API(tf.compat.v2.__internal__.monitoring),即使你没有TPU,estimator模块的导入过程也会触发这个错误。同时tensorflow-hub 0.13.0与TensorFlow 2.4.1的兼容性也存在问题。

解决步骤

  1. 激活你的Miniconda环境:
conda activate CFS
  1. 卸载当前不兼容的包:
pip uninstall -y tensorflow-estimator tensorflow-hub
  1. 安装与TensorFlow 2.4.1匹配的版本:
pip install tensorflow-estimator==2.4.0 tensorflow-hub==0.12.0
  1. 验证安装成功:
    运行以下代码测试导入是否正常:
import tensorflow as tf
import tensorflow_hub as hub
print("TensorFlow版本:", tf.__version__)
print("TensorFlow Hub版本:", hub.__version__)

如果没有报错,说明问题已解决。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.26 22:43:13