Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named tensor flow -- iPython notebook

I understand this may be an old question, but still I cannot find solution from off-the-shelf Q$A. Here is the problem:

I am following Udacity "Machine Learning" and its assignments, and need use iPythonNotebook & tensorflow. Details : https://github.com/Omarito2412/udacity-deeplearning

Assignment2 requires tensorflow. BTW, I already installed Anaconda, already made tensorflow working on Pycharm on the same computer which is Macbook, but do not know how to make it work on iPythonNotebook environment.

The codes are quite simple, as follows:

import numpy as np
import tensorflow as tf
from six.moves import cPickle as pickle
from six.moves import range

and the error message is as follows:

ImportError                               Traceback (most recent call last)
<ipython-input-1-0970743dd90d> in <module>()
      2 # before proceeding further.
      3 import numpy as np
----> 4 import tensorflow as tf
      5 from six.moves import cPickle as pickle
      6 from six.moves import range

ImportError: No module named tensorflow

Thanks. Any suggestions ?

PS: I have this problem on two MacBooks, and both MacBooks run Pycharm+tensorflow well.

like image 278
Bill Ancalagon the black Avatar asked Feb 07 '23 19:02

Bill Ancalagon the black


2 Answers

You should deactivate and re-activate the environment

source deactivate tensorflow
source activate tensorflow
like image 143
Nam Vu Avatar answered Feb 09 '23 10:02

Nam Vu


After I tried Anaconda-installation (I was using the other installation methods, which are all shown in the link below) https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#anaconda-installation It worked ...

Further, on terminal activate tensorflow

>>> source activate tensorflow

before open iPython Notebook

>>> ipython notebook

At last, I have to restart my macbook to make it work....

like image 44
Bill Ancalagon the black Avatar answered Feb 09 '23 10:02

Bill Ancalagon the black