Anaconda3下安装TensorFlow



之前按百度上一些方法安装TensorFlow,由于刚接触或者因为方法描述太过简单导致没有安装成功,后来自己尝试着装成功之后,详细总结如下:

第一步:打开Anaconda Prompt,输入:

condaconfig --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

condaconfig --set show_channel_urls yes

Anaconda3下安装TensorFlow

查看:当前用户目录下出现.condarc文件

Anaconda3下安装TensorFlow

第二步:输入 conda installpip

Anaconda3下安装TensorFlow

出现如下内容:
(C:\Users\Administrator\Anaconda3) C:\Users\Administrator>conda install pip
Fetching package metadata .............
Solving package specifications: ..........

Package plan for installation in environment C:\Users\Administrator\Anaconda3:

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    conda-env-2.6.0            |                0          498 B  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    vc-14                      |                0          703 B  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    requests-2.14.2            |           py35_0         705 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    pip-9.0.1                  |           py35_1         1.7 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    pyopenssl-16.2.0           |           py35_0          70 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    conda-4.3.30               |   py35hec795fb_0         541 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    ------------------------------------------------------------
                                           Total:         3.0 MB

The following NEW packages will be INSTALLED:

    conda-env: 2.6.0-0       https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    vc:        14-0          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

The following packages will be UPDATED:

    conda:     4.2.9-py35_0  defaults                                                --> 4.3.30-py35hec795fb_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    pip:       8.1.2-py35_0  defaults                                                --> 9.0.1-py35_1          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    pyopenssl: 16.0.0-py35_0 defaults                                                --> 16.2.0-py35_0         https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    requests:  2.11.1-py35_0 defaults                                                --> 2.14.2-py35_0         https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

Proceed ([y]/n)? y

Fetching packages ...
conda-env-2.6. 100% |###############################| Time: 0:00:00   0.00  B/s
vc-14-0.tar.bz 100% |###############################| Time: 0:00:00   0.00  B/s
requests-2.14. 100% |###############################| Time: 0:00:00   1.65 MB/s
pip-9.0.1-py35 100% |###############################| Time: 0:00:01   1.58 MB/s
pyopenssl-16.2 100% |###############################| Time: 0:00:00   1.15 MB/s
conda-4.3.30-p 100% |###############################| Time: 0:00:00   1.42 MB/s
Extracting packages ...
[      COMPLETE      ]|##################################################| 100%
Unlinking packages ...
[      COMPLETE      ]|##################################################| 100%
Linking packages ...
[      COMPLETE      ]|##################################################| 100%

(C:\Users\Administrator\Anaconda3) C:\Users\Administrator>pip install scikit-learn
Requirement already satisfied: scikit-learn in c:\users\administrator\anaconda3\lib\site-packages

(C:\Users\Administrator\Anaconda3) C:\Users\Administrator>pip install tensorflow
Collecting tensorflow
  Downloading tensorflow-1.4.0-cp35-cp35m-win_amd64.whl (28.3MB)
    100% |████████████████████████████████| 28.3MB 28kB/s
Collecting protobuf>=3.3.0 (from tensorflow)
  Downloading protobuf-3.5.0-py2.py3-none-any.whl (388kB)
    100% |████████████████████████████████| 389kB 152kB/s
Requirement already satisfied: six>=1.10.0 in c:\users\administrator\anaconda3\lib\site-packages (from tensorflow)
Collecting numpy>=1.12.1 (from tensorflow)
  Downloading numpy-1.13.3-cp35-none-win_amd64.whl (13.1MB)
    100% |████████████████████████████████| 13.1MB 47kB/s
Collecting enum34>=1.1.6 (from tensorflow)
  Downloading enum34-1.1.6-py3-none-any.whl
Requirement already satisfied: wheel>=0.26 in c:\users\administrator\anaconda3\lib\site-packages (from tensorflow)
Collecting tensorflow-tensorboard<0.5.0,>=0.4.0rc1 (from tensorflow)
  Downloading tensorflow_tensorboard-0.4.0rc3-py3-none-any.whl (1.7MB)
    100% |████████████████████████████████| 1.7MB 145kB/s
Requirement already satisfied: setuptools in c:\users\administrator\anaconda3\lib\site-packages\setuptools-27.2.0-py3.5.egg (from protobuf>=3.3.0->tensorflow)
Collecting markdown>=2.6.8 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
  Downloading Markdown-2.6.9.tar.gz (271kB)
    100% |████████████████████████████████| 276kB 163kB/s
Collecting bleach==1.5.0 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
  Downloading bleach-1.5.0-py2.py3-none-any.whl
Requirement already satisfied: werkzeug>=0.11.10 in c:\users\administrator\anaconda3\lib\site-packages (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
Collecting html5lib==0.9999999 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
  Downloading html5lib-0.9999999.tar.gz (889kB)
    100% |████████████████████████████████| 890kB 156kB/s
Building wheels for collected packages: markdown, html5lib
  Running setup.py bdist_wheel for markdown ... done
  Stored in directory: C:\Users\Administrator\AppData\Local\pip\Cache\wheels\bf\46\10\c93e17ae86ae3b3a919c7b39dad3b5ccf09aeb066419e5c1e5
  Running setup.py bdist_wheel for html5lib ... done
  Stored in directory: C:\Users\Administrator\AppData\Local\pip\Cache\wheels\6f\85\6c\56b8e1292c6214c4eb73b9dda50f53e8e977bf65989373c962
Successfully built markdown html5lib
Installing collected packages: protobuf, numpy, enum34, markdown, html5lib, bleach, tensorflow-tensorboard, tensorflow
  Found existing installation: numpy 1.11.1
    Uninstalling numpy-1.11.1:
      Successfully uninstalled numpy-1.11.1
Successfully installed bleach-1.5.0 enum34-1.1.6 html5lib-0.9999999 markdown-2.6.9 numpy-1.13.3 protobuf-3.5.0 tensorflow-1.4.0 tensorflow-tensorboard-0.4.0rc3

(C:\Users\Administrator\Anaconda3) C:\Users\Administrator>



第三步:pip installtensorflow

Anaconda3下安装TensorFlow

第四步:验证

import tensorflow as tf

hello = tf.constant('Hello,TensorFlow!')

sess = tf.Session()

print(sess.run(hello))