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?
I also got the same error. May be because of the version of tensorflow. After installing tensorflow 1.4.0, I got relief from the error.
Faced same issue on Ubuntu 16LTS when tensor flow was installed over existing python installation.
Workaround: 1.)Uninstall tensorflow from pip and pip3 sudo pip uninstall tensorflow sudo pip3 uninstall tensorflow
2.)Uninstall python & python3 sudo apt-get remove python-dev python3-dev python-pip python3-pip
3.)Install only a single version of python(I used python 3) sudo apt-get install python3-dev python3-pip
4.)Install tensorflow to python3 sudo pip3 install --upgrade pip
for non GPU tensorflow, run this command
sudo pip3 install --upgrade tensorflow
for GPU tensorflow, run below command sudo pip3 install --upgrade tensorflow-gpu
Suggest not to install GPU and vanilla version of tensorflow
use once tf.disable_v2_behavior() after that below error not come again.
If you get this on tensorflow 2.0.0+, it's very likely because the code isn't compatible with the newer version of tensorflow.
To fix this, run the
tf_upgrade_v2
script.The problem is with TensorFlow version; the one you are running is
2.0
or something above1.5
, whileplaceholder
can only work with1.4
.So simply uninstall TensorFlow, then install it again with version 1.4 and everything will work.
It may be the typo if you incorrectly wrote the
placeholder
word. In my case I misspelled it asplacehoder
and got the error like this:AttributeError: 'module' object has no attribute 'placehoder'