我按照主网站上的说明在anaconda中安装了tensorflow。但是'import tensorflow'仅适用于在anaconda的envs中的tensorflow文件夹中的python。 anaconda的python3.6没有导入tensorflow。
我也遇到了类似的挑战以下方式对我有用
第1步:安装最新的anaconda
第2步:C:> conda create -n tensorflow python = 3.5
虽然你的anaconda python是3.6 tensorflow工作在3.5
第3步:C:>激活tensorflow
(tensorflow)C:>#你的提示应该改变
第4步:
4.1:CPU命令
(tensorflow)C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.2.1-cp35-cp35m-win_amd64.whl
4.2:GPU命令
(tensorflow)C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.2.1-cp35-cp35m-win_amd64.whl
第5步(验证tensorflow的安装)
(开始新的终端)
$ python
(enter the following command)
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
the output should be
Hello, TensorFlow!
步骤6:打开Anaconda Navigator,将“应用程序”从“Root to Tensorflow”通道更改为(左上角)
第7步:现在安装你想要使用的所需的jupyter或spyder(安装后启动它将工作的笔记本)
执行安装步骤,但用3.6或36替换3.5或35.适合我。
conda create -n tensorflow python=3.6
activate tensorflow
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.2.1-cp36-cp36m-win_amd64.whl