win10用Anaconda安装Tensorflow步骤及问题解决过程

1.下载 Anaconda
在 > https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

寻找你与你电脑系统对应的版本,我这里使用 Anaconda3-4.2.0-Windows-x86_64.exe
下载并安装完成后,打开 CMD, 输入 ‘conda --version’, 会输出conda版本信息,类似
conda 4.2.5

Anaconda 安装成功。

接下来需要设置 Anaconda 仓库镜像,因为默认连接的是国外镜像地址,下载速度比较慢,我们把镜像地址改为清华大学开源软件镜像站,

  1. 添加“清华镜像”渠道, 在Anaconda Prompt中执行: conda config --add channelshttps://mirrors.ustc.edu.cn/anaconda/pkgs/free/ conda config --add channelshttps://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ conda config --add channelshttps://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --set show_channel_urls yes
  2. 删除配置文件中的 -default 行。路径C:\Users\用户名XXX.condarc
    win10用Anaconda安装Tensorflow步骤及问题解决过程_第1张图片
    2.安装 TensorFlow
    在 Anaconda Prompt 窗口或者cmd下输入以下命令,去创建tensorflow的conda环境:
    conda create -n tensorflow python=3.5
    按回车。表示创建 TensorFlow 依赖环境,

继续看控制台,直到出现

Proceed ([y]/n)? 

提示我们安装哪些依赖软件,输入‘y’,回车。
然后等待安装即可。

#
# To activate this environment, use:
# > activate tensorflow
#
# To deactivate this environment, use:
# > deactivate tensorflow
#
# * for power-users using bash, you must source
#

然后继续输入命令激活tensorflow这个环境:

activate tensorflow  

接下来正式安装tensorflow
由于国外的镜像下载比较慢,这里使用的是清华大学镜像仓库
注意:在conda 的tensorflow环境下输入

pip install --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple/
https://mirrors.tuna.tsinghua.edu.cn/tensorflow/windows/cpu/tensorflow-1.1.0-cp35-cp35m-win_amd64.whl

3.测试验证是否可以使用。
输入:Python,进入Python编程环境。然后输入:

import tensorflow as tf  
hello = tf.constant('Hello, TensorFlow!')  
sess = tf.Session() 
print(sess.run(hello))  

正确的话,会输出:Hello, TensorFlow!

问题及解决办法

1.若出现让你更新pip环境,按照要求更新即可
在这里插入图片描述
2.更新完可能会出现如下问题:
win10用Anaconda安装Tensorflow步骤及问题解决过程_第2张图片
这时候使用

python -m pip install --upgrade --force-reinstall pip

3.若出现错误:

C:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\dtypes.py:455:
FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is
deprecated; in a future version of numpy, it will be understood as
(type, (1,)) / ‘(1,)type’. _np_qint8 = np.dtype([(“qint8”, np.int8,
1)])
C:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\dtypes.py:456:
FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is
deprecated; in a future version of numpy, it will be understood as
(type, (1,)) / ‘(1,)type’. _np_quint8 = np.dtype([(“quint8”,
np.uint8, 1)])
C:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\dtypes.py:457:
FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is
deprecated; in a future version of numpy, it will be understood as
(type, (1,)) / ‘(1,)type’. _np_qint16 = np.dtype([(“qint16”,
np.int16, 1)])
C:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\dtypes.py:458:
FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is
deprecated; in a future version of numpy, it will be understood as
(type, (1,)) / ‘(1,)type’. _np_quint16 = np.dtype([(“quint16”,
np.uint16, 1)])
C:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\dtypes.py:459:
FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is
deprecated; in a future version of numpy, it will be understood as
(type, (1,)) / ‘(1,)type’. _np_qint32 = np.dtype([(“qint32”,
np.int32, 1)])
C:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\dtypes.py:462:
FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is
deprecated; in a future version of numpy, it will be understood as
(type, (1,)) / ‘(1,)type’. np_resource = np.dtype([(“resource”,
np.ubyte, 1)])

根据提示,去到安装anaconda的目录下,找到dtypes.py文档,我的路径是
ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework
找到dtypes.py文档,将文档里的
_

np_qint8 = np.dtype([(“qint8”, np.int8, 1)])
修改为
_np_qint8 = np.dtype([(“qint8”, np.int8,(1,))])

_np_quint8 ,_np_qint16,_np_quint16, _np_qint32,np_resource同理。

你可能感兴趣的:(win10用Anaconda安装Tensorflow步骤及问题解决过程)