TensorFlow安装过程记录

最近在做毕设,需要用到TensorFlow,之前没有接触过TensorFlow,安装过程中踩了不少坑,特此记录。

版本

  • 系统:windows 10
  • Anaconda版本:Anaconda3-5.3.1
  • Python版本:3.5.6
  • TensorFlow版本:1.1.0

过程

1 安装Anaconda
官网:https://www.anaconda.com/download/
清华镜像:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/(推荐)

2 在Anaconda中新建Python环境
打开Anaconda Prompt,输入命令:conda create -n tensorflow python=3.5

3 切换环境
Anaconda Prompt中输入命令:activate tensorflow

4 安装TensorFlow
Anaconda Prompt中输入命令:pip install -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

5 在PyCharm中使用TensorFlow

1)添加新的python解释器

File->Settings->Project Interpreter

TensorFlow安装过程记录
TensorFlow安装过程记录
TensorFlow安装过程记录
2)创建新的Project,使用刚才添加的解释器

File->New Project

TensorFlow安装过程记录

问题

分别在Anaconda和Pycharm中进行测试:import tensorflow as tf

1)Python3.7+TensorFlow2.1.0
Anaconda报错:ImportError:DLL load faild:找不到指定的模块。

2) Python3.7+TensorFlow1.13.1
Anaconda没问题,但Pycharm报错:ImportError:No module named tensorflow

3) Python3.7+TensorFlow1.9.0
Anaconda没问题,但Pycharm报错:ImportError:No module named tensorflow

4) Python3.5+TensorFlow1.1.0
Anaconda和Pycharm都没问题,但有警告: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)])

TensorFlow安装过程记录这是由于numpy版本过高,降低numpy版本即可。