Skip to main content
 首页 » 编程设计

python之tensorflow 'module' 对象没有属性 'contrib'

2025年04月02日30zhenyulu

我使用 pip 方法安装了 tensorflow(在 python 2.7,debian linux 上),如官方文档所示: https://www.tensorflow.org/versions/r0.9/get_started/os_setup.html#pip-installation

按照安装指示成功测试了安装,但是在执行教程时: https://www.tensorflow.org/versions/r0.9/tutorials/tflearn/index.html#construct-a-deep-neural-network-classifier

正确导入tensorflow后,试行时:

training_set = tf.contrib.learn.datasets.base.load_csv(filename=IRIS_TRAINING, target_dtype=np.int) 

我收到错误: tensorflow 'module' 对象没有属性 'contrib'

有人知道这可能是错的吗?

谢谢

请您参考如下方法:

问题解决了,原来我安装了 2 个 tensorflow 版本:

  1. 启动 $python 时,它使用 0.6 版本(没有 contrib 模块)
  2. 启动 $sudo python 时,它有最新的 0.9 版本,一切都像文档一样工作。