Spyder中加载tensorflow 终端加载tensorflow

问题描述:

配置好Anaconda环境,安装好tensorflow后,输入:source activate tensorflow,进入tensorflow环境。

打开Anaconda下的编辑器Spyder,输入import tensorflow,报错:No module named 'tensorflow'

问题解决:

进入tensorflow编辑环境后需要重新安装spyder插件。

在(tensoflow)环境下输入命令:conda install spyder

安装完成后,进入Anaconda目录,发现多出一个程序:Spyder(tensorflow)。

启动Spyder(tensorflow)看是否正常运行。


激活 tensorflow

$ source activate tensorflow
(tensorflow)$  # Your prompt should change.
# Run Python programs that use TensorFlow.
...
# When you are done using TensorFlow, deactivate the environment.
(tensorflow)$ source deactivate

运行 TensorFlow

打开一个 python 终端:

$ python

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print sess.run(hello)
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print sess.run(a+b)
42
>>>

猜你喜欢

转载自blog.csdn.net/zhangyake1989/article/details/79519905