我在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'>
>>>