1.使用 virtualenv 安装
1.1通过以下命令安装 pip 和 virtualenv
$ sudo easy_install pip
$ sudo pip install --upgrade virtualenv
1.2执行以下任一命令创建虚拟环境
创建一个文件夹
mkdir tensorflow
创建虚拟环境
virtualenv --system-site-packages -p python3 ./tensorflow
1.3激活虚拟环境
1.2安装成功后 执行
cd tensorflow
source bin/activate
激活后目录出现以下括号
(tensorflow) JLSdeMacBook-Pro:tensorflow jls$
1.4安装tensorflow
(tensorflow) JLSdeMacBook-Pro:tensorflow jls$ pip3 install tensorflow==1.9.0
1.5验证是否成功
因为安装的是python3 只能用python3使用 直接python执行窗口 import tensorflow会报错
(tensorflow) JLSdeMacBook-Pro:tensorflow jls$ python3
>>> import tensorflow as tf
>>> hello = tf.constant('Hello')
>>> sess = tf.Session()
2018-11-24 21:25:47.670390: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
>>> print sess.run(hello)
File "<stdin>", line 1
print sess.run(hello)
^
SyntaxError: invalid syntax
>>> print (sess.run(hello))
b'Hello'
2.安装扩展组建
2.1 安装 numpy
pip3 install numpy --upgrade
2.2 安装 matplotlib
pip3 install matplotlib --upgrade
2.3 安装jupyter
pip3 install jupyter --upgrade
安装后执行
(tensorflow) JLSdeMacBook-Pro:tensorflow jls$ jupyter notebook
[I 22:02:01.712 NotebookApp] 把notebook 服务cookie密码写入 /Users/jls/Library/Jupyter/runtime/notebook_cookie_secret
[I 22:02:02.416 NotebookApp] 启动notebooks 在本地路径: /Users/jls/Learning/deepLearning/tensorflow
[I 22:02:02.416 NotebookApp] 本程序运行在: http://localhost:8888/?token=7dbf8d39e6626e935cd1d665fe80cf04234882889ea485a1
[I 22:02:02.416 NotebookApp] 使用control-c停止此服务器并关闭所有内核(两次跳过确认).
[C 22:02:02.421 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=7dbf8d39e6626e935cd1d665fe80cf04234882889ea485a1
[I 22:02:03.483 NotebookApp] Accepting one-time-token-authenticated connection from ::1
[W 22:02:04.001 NotebookApp] 404 GET /apple-touch-icon-precomposed.png (::1) 20.37ms referer=None
[W 22:02:04.015 NotebookApp] 404 GET /apple-touch-icon.png (::1) 2.75ms referer=None
打开游览器
http://localhost:8888/tree
没有评论