- 1、添加镜像源
- 2、 新建虚拟环境
- 3、查看现有环境
- 4、激活环境
- 5、安装tensorflow
- 6、测试是否安装成功
打开anaconda prompt
添加国内源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --set show_channel_urls yes2、 新建虚拟环境
conda create --name tf20 python=3.73、查看现有环境
conda info --envs4、激活环境
输入activate tf20激活环境
5、安装tensorflow这里我装的是cpu版本,你根据自己情况
pip install tensorflow-cpu==2.2.0
在python环境中输入import tensorflow如果不报错说明好着
或者运行下列代码:
import tensorflow as tf import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' a = tf.constant(1.) b = tf.constant(2.) c = tf.add(a, b) print(float(c))



