1.安装anaconda
2.打开cmd(不翻墙)(换源需要先恢复默认再换源)
①切换为默认源
conda config --remove-key channels
②清华源
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 --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
2.tensorflow安装
找到需要的tensorflow版本以及需要的python版本
打开cmd
conda create -n tensorflow*.* python==3.*
activate tensorflow*.*
conda install tensorflow==*.*
直到看到done
3.测试是否安装成功
Anaconda prompt中
activate tensorflow*.*
import tensorflow as tf
没有报错即成功
4.使用tensorflow
打开pycharm,创建虚拟环境
注意这三部分,路径选择创建的tensorflow下的python.exe
py文件中输入
import tensorflow as tf
注:报错解决:
anaconda prompt中输入
activate tensorflow2.3
pip uninstall h5py
pip install h5py
pip太慢的话换conda ,可能会提示conda版本太旧,根据提示更新一下就好。