说明:已安装anaconda 3,Windows10系统
下载过慢可以输入一下代码载入清华镜像:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
三段代码分三次输入并执行。
如果需要使用pytorch,需要添加新的源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
-
打开 Anaconda Prompt
-
python -m pip install --upgrade pip # 升级 pip
-
conda create -n tensorflow python=3.6 # 创建虚拟环境tensorflow
conda info --envs # 检查虚拟环境是否安装
-
activate tensorflow #(激活切换到虚拟环境tensorflow)
conda deactivate # 退出激活环境
-
在虚拟环境下安装 tensorflow:
pip install tensorflow==1.13.1 -i https://pypi.tuna.tsinghua.edu.cn/simple/
-
输入python进入python编辑环境
依次输入以下代码检查tensorflow安装是否完成:import tensorflow as tf hello = tf.constant("hello,tensorflow!") sess = tf.Session() print(sess.run(hello)
输出结果:b’hello,tensorflow!’
exit()退出python编辑环境 -
conda install ipython # 在虚拟环境下安装ipython
-
然后安装ipykernel:
pip install ipykernel
-
最后将此kernel链接到jupyter notebook中 :
python -m ipykernel install --user --name tensorflow --display-name "TensorFlow 1.13.1"
-
输入jupyter notebook 打开jupyter -> new -> TensorFlow 1.13.1,输入以下代码检查安装