0

I installed tensorflow as described for Anaconda installation in the tensorflow.org. I could run the tensorflow in the Mac terminal just typing,

$ source activate tensorflow

$ python

import tensorflow as tf

But, when I run iPython notebook, it does not work by showing an error of no module named tensorflow. I felt like tensorflow was correctly installed but iPython notebook could not recognize it. Is there any way to fix it?

Thomas K
  • 39,200
  • 7
  • 84
  • 86
  • My answer here might help: http://stackoverflow.com/questions/38280739/how-to-make-conda-virtual-environments-persistent-and-available-for-tools-such-a – cel Jul 09 '16 at 11:17

2 Answers2

0

Please have a look at your path. When you do the command 'source activate tensorflow', your path may have changed. The example is following.

sherrie@sherrie-PC:~/tensorflow/tensorflow/examples/udacity$ source activate tensorflow
discarding /home/sherrie/anaconda2/bin from PATH
prepending /home/sherrie/anaconda2/envs/tensorflow/bin to PATH

Tensorflow is installed in the first path, instead of the second one. The most important step comes. Open your directory of 'anaconda' --> find the 'envs' --> open 'tensorflow' --> copy all files in 'sitepack0ages' to 'anaconda/lib/python2.7/sitepack-ages'. Done.

0

My answer is based on this other answer: Trouble with TensorFlow in Jupyter Notebook. I had the exact same problem, and I solved it by doing this:

Once your environment is activated, run "which jupyter" and verify if the path returned points to the /bin folder under your environment, something like /my_environments_path/my_tensorflow_environment_name/bin/jupyter. If this is already the case, your scenario is different from the one I had;

Run "which pip" and/or "which pip3". Odds are, you are executing pip or pip3 from a different location, so Jupyter is not being installed inside your environment. In my case, Python version was 3.6, but pip3 was being called from a different location. I ran "pip install jupyter", since pip was inside the /bin folder in my environment. Once I called the correct pip, I checked again the "which jupyter" command, and this time Jupyter was under my environment and I could import Tensorflow inside my notebooks. If no pip's path points to your environment, install pip inside it by running "conda install pip".

I hope this works, along with the additional information on the link above.