2016-05-17 211 views
1

我按照 https://www.tensorflow.org/versions/r0.8/get_started/os_setup.html#download-and-setup 上的说明在我的系统上安装了TensorFlow,并尝试了pip安装和anaconda安装。我试着运行几个例子,但没有一个能够工作。TensorFlow根本没有任何属性

>>> import tensorflow 
>>> tensorflow.InteractiveSession() 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
AttributeError: module 'tensorflow' has no attribute 'InteractiveSession' 
>>> a = tensorflow.zeros((2,2)) 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
AttributeError: module 'tensorflow' has no attribute 'zeros' 

我得到了许多其他功能相同的错误。我已经安装了支持GPU的TensorFlow 0.8,Python 3.5.1和Ubuntu 15.10 64bit。在我安装Anaconda(3)之前,我记得事情很顺利,我曾经得到Numpy和Scipy。之后我也对Python路径感到困惑。现在,当我尝试重新安装TensorFlow,使用

sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.8.0-cp34-cp34m-linux_x86_64.whl 
tensorflow-0.8.0-cp34-cp34m-linux_x86_64.whl is not a supported wheel on this platform. 

要重置我的系统上的蟒蛇,我甚至重新安装Ubuntu的,但它并没有太大的帮助。应该做些什么才能使事情发挥作用?

+0

在Python shell中打印dir(tensorflow)时会得到什么结果?我怀疑Python会从你的路径中选择一个不同的文件或目录 - 例如你在当前目录下有一个名为'tensorflow.py'的文件吗? – mrry

+0

@mrry 'print(dir(tensorflow))' print this '['__doc__','__loader__','__name__','__package__','__path__','__spec__']' –

回答

0

如果您已经编译并安装来源的tensorflow。 安装完成后,从您保留张量源代码的git克隆(通常在〜/ tensorflow中)的文件夹中出来,比尝试以下测试是否已成功编译并安装它。

import tensorflow as tf 
hello = tf.constant('Hello, TensorFlow!') 
sess = tf.Session() 
print(sess.run(hello)) 

,如果你仍然在tensorflow文件夹,并尝试签比它会导致以下错误或类似的错误。

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

相关问题