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 免激活版本