Reputation: 99
In MacOS, I used Pip to install tensorflow following the standard instructions on the tensorflow.org website.
When I start Spyder, I am able to execute the following instruction without error:
import tensorflow as tf
But when I attempt to run the following instruction: g = tf.Graph(), I get the following error:
AttributeError: 'module' object has no attribute 'Graph'
When I do the same in "python" or "ipython" instead of Spyder, I do not get this error. But I would like to use Spyder.
I tried the install with Conda instead of Pip, but got the same symptoms.
Upvotes: 1
Views: 11552
Reputation: 1122
For anyone coming in recent times, this error might come up when using Keras. Solved it by changing all
from keras.something import something
to
from tensorflow.keras.something import something
Can see github issue about this.
Upvotes: 1
Reputation: 26
These steps worked for me: (linux, pip, tf1.4-gpu)
pip uninstall tensorflow-gpu
rm -rf ~/.cache/pip/*
pip install -U tensorflow-gpu
Upvotes: 1