2017-02-20 166 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

相關問題