tensorflow有多种安装方式,用anacode安装较为简单,因此选用了该方式。
阅读目的:学会在mac上使用anacode安装tensorflow
说明:电脑上已经安装了python3.5(其他版本也可以,但可能会遇到和tensorflow版本不匹配问题)、anacode(anacode安装教程)
安装TensorFlow
- 终端输入
conda create -n tensorflow python=3.5
,若出现command not found: conda,则说明anacode环境变量没有配置好,可参考anacode教程。命令成功结果:提示,输入 y
运行结果
- 激活环境,激活后终端前会出现(tensorflow)
source activate tensorflow
- 安装tensorflow
(tensorflow) ➜ ~ pip install tensorflow
- 若上述步骤成功运行,则tensorflow已经安装完成。
- 测试tensorflow是否成功完成,输入
python3
进入python环境,
>>> import tensorflow as tf
运行不报错,则tensorflow安装完成。
可能遇到的问题
- TensorFlow找不到匹配的版本。
-
因为tensorflow的版本和python的版本是对应的,部分Python版本对应的tensorflow版本没有,所以会出现以上问题。
-
Python必须是64bit,若是32bit,也找不到对应的TensorFlow版本。