2017-02-20 164 views
1

我在Jupyter笔记本上写下面的代码。AttributeError:模块'tensorflow'没有属性'图'

import tensorflow as tf 
g = tf.Graph() 

而我在执行此简单代码时遇到以下错误。

AttributeError: module 'tensorflow' has no attribute 'Graph'

如果我从控制台执行相同的操作。有用。任何想法发生了什么。

更多信息:(测试我的virtualenv)

IPython中,jupyter,Python版本:

(test) [email protected]:~/tensorflow$ which ipython3 
/home/xingzhou/tensorflow/test/bin/ipython3 
(test) [email protected]:~/tensorflow$ which jupyter 
/home/xingzhou/tensorflow/test/bin/jupyter 
(test) [email protected]:~/tensorflow$ which python3 
/home/xingzhou/tensorflow/test/bin/python3 

从控制台执行:

(test) [email protected]:~/tensorflow$ python3 
Python 3.5.2 (default, Nov 17 2016, 17:05:23) 
[GCC 5.4.0 20160609] on linux 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import tensorflow as tf 
>>> g = tf.Graph() 
>>> type(g) 
<class 'tensorflow.python.framework.ops.Graph'> 
>>> 

回答

1

我通过重新启动解决了这个问题Jupyter Notebook内核。有点奇怪。

0

一个简单的解决方案为我工作。 从anaconda navigator先去环境和这样的形象

enter image description here

我把它命名为tensorflow创建tensorflow环境。然后从右边的下拉菜单中选择全部并搜索tensorflow。

enter image description here

选择它并点击应用。它会下载一些额外的软件包以及tensorflow。完成后,从家中选择张量流量,你应该很好走。它在这里起作用。

enter image description here

相关问题