Mac 下 TensorFlow配置

本文介绍如何在Mac OS X 10.12.3系统上使用Python 2.7.10安装TensorFlow,并通过Virtualenv创建独立的工作环境。此外,还介绍了如何在PyCharm 2016.2版本中配置项目。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Python版本: 2.7.10
Mac os版本: 10.12.3

1、Python安装

Python安装: brew install python
查看Python版本:
(demoTensorflow) XLC-2:demoTensorflow xianglingchuan$ python -V
Python 2.7.10

Pip 安装: sudo easy_install pip

2、Virtualenv安装

用pip命令安装:

Mac:pythonVirtualenv root$ sudo pip install --upgrade virtualenv

建创工作目录

Mac:pythonVirtualenv root$ virtualenv --system-site-packages /Users/root/software/python/pythonVirtualenv/demoTensorflow
New python executable in /Users/root/software/python/pythonVirtualenv/demoTensorflow/bin/python
Installing setuptools, pip, wheel...done.

进入目录激活沙箱

Mac:pythonVirtualenv root$ cd demoTensorflow/
Mac:pythonVirtualenv root$ ls
bin     include     lib     pip-selfcheck.json
Mac:pythonVirtualenv root$ source bin/activate

退出沙箱

Mac:pythonVirtualenv root$ deactivate

3、TensorFlow安装

在virtualenv里安装tensorflow

pip install –ignore-installed –upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0rc0-py2-none-any.whl

Mac:pythonVirtualenv root$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0rc0-py2-none-any.whl
Collecting tensorflow==0.8.0rc0 from https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0rc0-py2-none-any.whl
  Using cached https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0rc0-py2-none-any.whl
Collecting six>=1.10.0 (from tensorflow==0.8.0rc0)
  Using cached six-1.11.0-py2.py3-none-any.whl
Collecting wheel (from tensorflow==0.8.0rc0)
  Using cached wheel-0.30.0-py2.py3-none-any.whl
Collecting numpy>=1.10.1 (from tensorflow==0.8.0rc0)
  Using cached numpy-1.14.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Collecting protobuf==3.0.0b2 (from tensorflow==0.8.0rc0)
  Using cached protobuf-3.0.0b2-py2.py3-none-any.whl
Collecting setuptools (from protobuf==3.0.0b2->tensorflow==0.8.0rc0)
  Using cached setuptools-38.4.0-py2.py3-none-any.whl
Installing collected packages: six, wheel, numpy, setuptools, protobuf, tensorflow
Successfully installed numpy-1.14.0 protobuf-3.0.0b2 setuptools-38.4.0 six-1.11.0 tensorflow-0.8.0rc0 wheel-0.30.0
(demoTensorflow) XLC-2:demoTensorflow xianglingchuan$ 

运行tensorflow

Mac:pythonVirtualenv root$ python
Python 2.7.10 (default, Jul 30 2016, 19:40:32) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello,TensorFlow!')
>>> sess = tf.Session()
>>> print sess.run(hello)
Hello,TensorFlow!
>>> 

4、Pycharm中项目的配置

版本: PyCharm2016.2 免激活版本
这里写图片描述

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值