anaconda 下安装 TensorFlow

  1. 下载安装anaconda(Anaconda3-2018.12-Windows-x86_64);

    1. 配置conda默认链接镜像地址,使用清华大学开源软件镜像:
    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
    
  2. 在Anaconda Prompt中输入命令;

    1. 查看当前可用Tensorflow版本:
    conda search --full -name tensorflow
    

    其中 _py35, _py37是当前Tensorflow支持的python版本
    2. 创建Tensorflow环境,安装python3.7:

    conda create --name tensorflow python=3.7
    

    查看所有环境名: conda info --envs
    3. 激活创建的tensorflow环境:

    activate tensorflow
    

    退出当前激活的环境: deactivate
    4. 在tensorflow环境中,正式安装Tensorflow包:

    pip install --upgrade --ignore-installed tensorflow
    
    1. 验证是否安装成功:
      进入python环境,并输入以下代码:
    > python
    
    import tensorflow as tf
    hello = tf.constant('hello, world')
    sess = tf.Session()
    print(sess.run(hello))
    


    安装完毕

  3. 在jupyter notebook中使用tensorflow;

    1. 启用tensorflow环境;
     activate tensorflow
    
    1. 安装ipython,和notebook;
    conda install ipython
    
    conda install jupyter
    
    ipython kernelspec install-self --user
    

    如果最后提示如下信息,则配置成功

    Installed kernelspec python3 in C:UsersXXXJupyterkernelspython3
    

    进入jupyter notebook尝试使用tensorflow


Jupyter Notebook 5.7.6,会出现打开空白页的情况;

  1. 退回Jupyter Notebook老版本解决
  2. 修改 Anacondaenv你的环境Libsite-packages otebook otebookapp.py, init_mime_overrides方法,最后追加
    mimetypes.add_type('application/javascript','.js')
    
原文地址:https://www.cnblogs.com/xiong233/p/10609300.html