win7下安装Anaconda3和tensorflow

win7搭建Anaconda3及tensorflow环境
其中:本地python为v3.6.5, Anaconda3为Anaconda3-5.2.0-Windows-x86_64

1 安装python

python3和python2环境变量共存设置

1
%Python3%;%Python3%Scripts;%Python2%;%Python2%Scripts;

2 安装及配置pip

安装及升级
python -m pip install –upgrade pip

国内pip源
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/

更改pip源
windows环境下,添加或修改为:

C:Userswillpippip.ini
1
2
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

linux环境下,添加或修改为:

$HOME/pip/pip.conf
1
2
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

3 安装及配置Anaconda3

3.1 下载Anaconda3

Anaconda3-5.2.0,进行安装

3.2 配置Anaconda3环境变量

新建系统变量:ANACONDA3C:/MyProgramFiles/Anaconda3
在Path添加

1
%ANACONDA3%;%ANACONDA3%/Library/mingw-w64/bin;%ANACONDA3%/Library/bin;%ANACONDA3%/Scripts;

参考后,目前没有配置:%ANACONDA3%/Library/usr/bin,原因:没找到路径,可能是win没有。

测试是否配置成功:命令行下输入:conda

3.3 登录jupyter

运行Jupyter Notebook。
看到http://localhost:8888/?token=...表示成功

3.4 修改coanda包管理源

1
2
3
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

可能有用,coanda删除源

1
coanda config --remove channels https:

4 安装tensorflow

tensorflow版本分为:

  • CPU版本:pip3 install –upgrade tensorflow
  • GPU版本:pip3 install –upgrade tensorflow-gpu(电脑不支持)

安装cpu版本
pip install –upgrade tensorflow

tensorflow安装成功测试

1
2
3
4
5
python
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))

Ref

  1. Anaconda安装与环境配置
  2. TensorFlow在Windows环境下的搭建

原文:大专栏  win7下安装Anaconda3和tensorflow


猜你喜欢

转载自www.cnblogs.com/chinatrump/p/11446036.html