How to use tensorflow on spyder?
The first answer doesn't work properly, it installs all the old libraries.
By old I mean : It installs version : 0.10.0
Latest Version : 1.0.0 (Can be installed in the tensorflow website)
Install using the below link: https://www.tensorflow.org/versions/r0.12/get_started/os_setup#anaconda_installation
After the installation, I was able to work with IPython too, without any issues. Please don't skip any steps
I had tensorflow running in ipython and from a command line. Where you have tensorflow working, find out the search path by typing
import sys
print (sys.path)
In spyder ipython console do the same thing and you will probably get different answers. Now drag the mouse over path where tensorflow works and copy it. Start a program with the command
import sys
sys.path = [ path cut from ipython window]
For example, my command line with working tensorflow had the path
['', '/home/gaw/anaconda3/envs/tensorflow/lib/python35.zip', \
'/home/gaw/anaconda3/envs/tensorflow/lib/python3.5', \
'/home/gaw/anaconda3/envs/tensorflow/lib/python3.5/plat-linux', \
'/home/gaw/anaconda3/envs/tensorflow/lib/python3.5/lib-dynload', \
'/home/gaw/anaconda3/envs/tensorflow/lib/python3.5/site-packages', \
'/home/gaw/anaconda3/envs/tensorflow/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg']
My spyder window where tensorflow did not work had the path
sys.path = ['', '/home/gaw/anaconda3/envs/tensorflow/lib/python35.zip', '/home/gaw/anaconda3/envs/tensorflow/lib/python3.5', '/home/gaw/anaconda3/envs/tensorflow/lib/python3.5/plat-linux', '/home/gaw/anaconda3/envs/tensorflow/lib/python3.5/lib-dynload', '/home/gaw/anaconda3/envs/tensorflow/lib/python3.5/site-packages', '/home/gaw/anaconda3/envs/tensorflow/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg']
In spyder I put
sys.path = ['', '/home/gaw/anaconda3/envs/tensorflow/lib/python35.zip', \
'/home/gaw/anaconda3/envs/tensorflow/lib/python3.5', \
'/home/gaw/anaconda3/envs/tensorflow/lib/python3.5/plat-linux', \
'/home/gaw/anaconda3/envs/tensorflow/lib/python3.5/lib-dynload', \
'/home/gaw/anaconda3/envs/tensorflow/lib/python3.5/site-packages', \
'/home/gaw/anaconda3/envs/tensorflow/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg']
Set the path in spyder to the same value as the one that works.
After installing Tensorflow using Anaconda based on Installing TensorFlow on Windows you must change your Environment for Spyder.
1) Open Anaconda Navigator
2) In top left corner you see Selector: "Applications on: base(root)"
3) Change: "base root" for "Tensorflow" it assumes that it was already installed based on link above
4) Install Spyder
5) Open Spyder and make your first test file:
010 import tensorflow as tf
020 hello = tf.constant('Hello, TensorFlow!')
030 sess = tf.Session()
040 print(sess.run(hello))
6) Run it in Spyder and it will work
System default python maybe used on command line, first verify that you are using the python from anaconda distro. Set up the environment variables first.
If you are not building tensorflow with GPU support. you can install tensorflow through conda in one command.
$ conda install -c https://conda.anaconda.org/jjhelmus tensorflow
in Spyder: import tensorflow as tf. and you're good to go.