一、安装tensorflow

一、anaconda

在安装tensorflow之前,强烈建议安装anaconda。因为它已经集成了很多的Python第三方库。安装它之后就可以不同一个个下载库并解决他们之间的依赖关系,是十分方便的。

1)前往anaconda下载页面: https://www.anaconda.com/download/

下载对应的anaconda

本文环境是:Mac os、python2.7

2)安装anaconda

Mac下运行安装: Anaconda2-5.2.0-MacOSX-x86_64.pkg

linux下执行命令:bash  Anaconda2-5.2.0-MacOSX-x86_64.sh

3) 安装以后可以重启

sudo reboot

二、建立激活tensorflow运行环境

conda create -n tensorflow python=2.7

source activate tensorflow

三、安装tensorflow

pip install tensorflow

四、验证是否安装成功

$ python

>>> import tensorflow as tf

>>> hello = tf.constant('hello tensorflow')

>>> sess = tf.Session()

>>> print(sess.run(hello))

hello tensorflow

当没有报错,且界面出现hello tensorflow字样的时候,说明安装成功了

猜你喜欢

转载自www.cnblogs.com/lay2017/p/9196082.html