一、安装Anaconda
https://www.anaconda.com/download/
官网下载Anaconda后,按照其他博客安装好。
详细安装链接:Anaconda
注意安装过程中一直点下一步,
**注意:**选择安装路径,路径所在文件夹必须是空的。
**注意:**此处把两个地方都勾选上,这样环境变量就自动添加到计算机下了。
安装结束后,在开始栏找到Anaconda,打开Anaconda Prompt,进入终端后方便镜像下载。
二、安装Anaconda
0.导入镜像包
设置额外的源,直接从速度快的源进行下载。
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.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/
参考链接:https://blog.csdn.net/feifei3211/article/details/80361227
1.创建Python环境
conda create --name tensorflow14 python=3.6
代表创建一个python3.6的环境,我们把它命名为tensorflow14
2.激活环境
conda activate tensorflow14
激活环境,方便在该环境中安装库
3.安装Spyder编译器
首先升级pip,防止出现问题
python -m pip install -i https://pypi.doubanio.com/simple/ --upgrade pip
python -m pip install -i https://pypi.doubanio.com/simple/ --upgrade setuptools
然后安装Spyder,5.0.5版本安装起来比较稳定、界面更好看
conda install spyder==5.0.5
如果安装失败,则重新执行此行命令。多次安装均失败,则用记事本打开C:\Users\电脑用户名路径下的.condarc,删掉 - defaults,再重新执行此行代码。
4.安装tensorflow的1.14版本
镜像安装tensorflow
pip install -i https://pypi.doubanio.com/simple/ tensorflow==1.14
5.训练测试代码
输入
python
进入到python内部,输入以下代码测试tensorflow是否安装成功
import tensorflow as tf
sess = tf.Session()
a = tf.constant(1)
b = tf.constant(2)
print(sess.run(a+b))
出现以下界面,则安装成功。
退出python返回虚拟环境中
exit()
6.镜像安装Tensorflow对应Keras2.2.5版本:
pip install -i https://pypi.doubanio.com/simple/ keras==2.2.5
其他库的安装也可以使用此行代码,只需更改库名即可。
Tensorflow对应的Keras版本:
7.安装其他库
pip install -i https://pypi.doubanio.com/simple/ opencv-python
pip install -i https://pypi.doubanio.com/simple/ pillow
pip install -i https://pypi.doubanio.com/simple/ matplotlib
如需安装其他库,仅需将库名修改。
8.所有需要的库安装好后,训练模型