Tensorflow_001.在macOS上安装Tensorflow

1、下载安装Anaconda

Anaconda创建环境:

conda create -n py36 python=3.6  //下面是创建python=3.6版本的环境,取名叫py36

删除环境

conda remove -n py36 --all

激活环境

source activate py36  //下面这个py36是个环境名

退出环境

source deactivate


2、创建名为tensorflow运行环境

conda create -n tensorflow pip python=2.7 # or python=3.3, etc.

3、激活当前环境

source activate tensorflow

4、安装Tensorflow

 

pip install --ignore-installed --upgrade TF_PYTHON_URL

TF_PYTHON_URL为Tensorflow软件包网站,可在https://www.tensorflow.org/install/pip查看,这是1.12.0的网址

网址
Linux的
Python 2.7仅限CPUhttps://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.12.0-cp27-none-linux_x86_64.whl
Python 2.7 GPU支持https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.12.0-cp27-none-linux_x86_64.whl
Python 3.4仅限CPUhttps://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.12.0-cp34-cp34m-linux_x86_64.whl
Python 3.4 GPU支持https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.12.0-cp34-cp34m-linux_x86_64.whl
Python 3.5仅限CPUhttps://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.12.0-cp35-cp35m-linux_x86_64.whl
Python 3.5 GPU支持https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.12.0-cp35-cp35m-linux_x86_64.whl
Python 3.6仅限CPUhttps://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.12.0-cp36-cp36m-linux_x86_64.whl
Python 3.6 GPU支持https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.12.0-cp36-cp36m-linux_x86_64.whl
macOS(仅限CPU)
Python 2.7https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py2-none-any.whl
Python 3.4,3.5,3.6https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl
视窗
Python 3.5仅限CPUhttps://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.12.0-cp35-cp35m-win_amd64.whl
Python 3.5 GPU支持https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.12.0-cp35-cp35m-win_amd64.whl
Python 3.6仅限CPUhttps://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.12.0-cp36-cp36m-win_amd64.whl
Python 3.6 GPU支持https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.12.0-cp36-cp36m-win_amd64.whl

出现错误:Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/wl/pd1h6scx22bf7b_f1st_w82h0000gn/T/pip-install-kzk5nbp5/gast/...

解决方法:这意味着您的setuptools已过期。
您可以通过以下方式解决此问题pip install --upgrade setuptools

5、验证运行

调用python

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值