win10 + Anaconda +python 3.7 tensorflow安装
step1:安装Anaconda
下载链接:link
图片:
第二个选项看你自己,如果想用anaconda中python环境就勾选,想用自己本地的(电脑之前配置了python)就不用勾选。
step2:安装Tensorflow的anaconda虚拟环境
为什么要使用anaconda安装虚拟环境,在该发行版本中,你可能有很多应用,但是每个应用需要的python或者tensorflow等版本不一样,这时使用虚拟环境就起作用了,每个环境安装你所需要的版本。
首先,建立一个工作目录,之后进入该工作目录(路径名字根据自己情况设置)
之后建立一个名为tendorflow的工作目录:
命令 | 说明 |
---|---|
conda create | 建立虚拟空间 |
– | – |
–name tendorflow | 建立名为tensorflow环境 |
– | – |
python=3.5 | 制定虚拟空间python版本为3.5 |
– | – |
anaconda | 加入此选项,会在虚拟环境中安装除python以外的其他一些包。不加入,就会建立一个空环境 |
之后进行报的安装。
安装完成之后,可以使用以下命令测试
进入虚拟环境
conda activeate tensorflow
退出虚拟环境
conda deactivate
step3:在虚拟环境中安装tensorflow和keras
启动之前的虚拟环境
conda activeate tensorflow
安装tensorflow cpu版本
pip install tensorflow
安装keras
pip install keras
在执行过程中,有可能需要更新pip,按照命令提示更新就可。可能还会出现以下错误:
一、ERROR: Cannot uninstall ‘wrapt’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
解决办法:
输入:pip install -U --ignore-installed wrapt enum34 simplejson netaddr
二、ERROR: tensorboard 1.14.0 has requirement setuptools>=41.0.0, but you’ll have setuptools 39.1.0 which is incompatible.
原因:
setuptools 版本太低
解决方法: 更新setuptools版本,输入: pip install --upgrade setuptools
至此,安装成功。
使用测试。
step4:启动jupyter notebook
之前在建立anaconda环境时,已经安装了jupyter notebook,现在只需切换到之前创建的工作目录,启动anaconda环境,启动据jupyter即可。
cd 你之前创建的工作目录 **(step2)将会显示你的工作目录下文件夹**
conda activate tensorflow
jupyter notebook
效果如图:
创建新文件,执行命令(ctrl+shifter)
命令行ctrl+c退出。