Question
Asked By – user3023715
I’ve been trying to use tensorflow for two days now installing and reinstalling it over and over again in python2.7 and 3.4. No matter what I do, I get this error message when trying to use tensorflow.placeholder()
It’s very boilerplate code:
tf_in = tf.placeholder("float", [None, A]) # Features
No matter what I do I always get the trace back:
Traceback (most recent call last):
File "/home/willim/PycharmProjects/tensorflow/tensorflow.py", line 2, in <module>
import tensorflow as tf
File "/home/willim/PycharmProjects/tensorflow/tensorflow.py", line 53, in <module>
tf_in = tf.placeholder("float", [None, A]) # Features
AttributeError: 'module' object has no attribute 'placeholder'
Anyone know how I can fix this?
Now we will see solution for issue: TensorFlow, “‘module’ object has no attribute ‘placeholder'”
Answer
It happened to me too. I had tensorflow and it was working pretty well, but when I install tensorflow-gpu along side the previous tensorflow this error arose then I did these 3 steps and it started working with no problem:
- I removed tensorflow-gpu, tensorflow, tensorflow-base packages from Anaconda. Using.
conda remove tensorflow-gpu tensorflow tensorflow-base
- re-installed tensorflow. Using
conda install tensorflow
This question is answered By – farnaz jazayeri
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0