1
votes

I installed TensorFlow on my system following the instructions on https://www.tensorflow.org/versions/r0.8/get_started/os_setup.html#download-and-setup and tried both the pip installation and anaconda installation. I tried running a few examples but none of them worked.

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

I get the same error for many other functions. I have installed TensorFlow 0.8 with GPU support, Python 3.5.1 and Ubuntu 15.10 64bit. I remember things worked well before I installed Anaconda(3), which I did to get Numpy and Scipy. I also kind of messed with the python paths afterwards. Now when I try to reinstall TensorFlow, using

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.

To reset the python on my system, I even reinstalled Ubuntu but it did not help much. What should be done to get things working?

1
What result do you get when you print dir(tensorflow) in the Python shell? I suspect Python is picking up a different file or directory from your path - e.g. do you have a file called tensorflow.py in the current directory? - mrry
@mrry 'print(dir(tensorflow))' prints this '['doc', 'loader', 'name', 'package', 'path', 'spec']' - Gaurav Waghmare

1 Answers

0
votes

In case you have compiled and installed tensorflow from its sources. Once your installation is complete come out of the folder where you kept your git clone of tensorflow sources (Usually in ~/tensorflow) than try the following test of whether you have compiled and installed it successfully or not.

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

if you are still in the tensorflow folder and try to check than it'll result in following error or similar errors.

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