简体   繁体   中英

tensorflow works in anaconda console, fails in notebook with:.ModuleNotFoundError: No module named 'tensorflow'

following the guide to install tensorflow using anaconda seems to work as:

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))

prints out hello. but the same code in a notebook gets:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-25b92e4d5dec> in <module>()
----> 1 import tensorflow as tf
      2 hello = tf.constant('Hello, TensorFlow!')
      3 sess = tf.Session()
      4 print(sess.run(hello))

ModuleNotFoundError: No module named 'tensorflow'

i started the notebook with jupyter notebook in the acaconda prompt that said:

(tensorflow) D:\ray\dev\ml\mit>

in one of my user directories.

starting jupyter notebook from the windows start menu fails also.

what is the correct way to start jupyter notebook?

First, activate the anaconda environment which you have tensorflow installed. Then

conda install nb_conda

Still in that environment, run jupyter notebook

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM