使用虚拟机装ubuntu然后跑tensorflow体验不要太差,性能不好,代码复制黏贴不好不折腾不死星人必须原生裸跑tensorflow
两种安装方式:
1、在 OS X 系统上安装, homebrew, 以便能够使用 homebrew 中的 Python 安装 TensorFlow.然后执行
brew install python
2、# 当前版本只支持 CPU
命令行输入$ pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl
如果以上就直接成功那恭喜你运气实在太好了,有问题的向下看:
但是以上两种办法均会面临一个问题,主要好像是mac系统上依赖six-1.4.1这个包但是呢版本又有点过低,因为系统依赖写了保护你还删除不了所以因为这个搞死安装不成功tf
会报如下错误:
Found existing installation: six 1.4.1
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py”, line 215, in main
status = self.run(options, args)
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py”, line 342, in run
prefix=options.prefix_path,
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py”, line 778, in install
requirement.uninstall(auto_confirm=True)
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py”, line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py”, line 115, in remove
renames(path, new_path)
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py”, line 267, in renames
shutil.move(old, new)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 302, in move
copy2(src, real_dst)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 131, in copy2
copystat(src, dst)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: ‘/var/folders/vq/1d39hprd08397h_x0zs5dvzw0000gn/T/pip-VAAk2t-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info’
解决之道:
这是System Integrity Protection的问题,解决的办法是关闭保护SIP。具体操作如下:1. 重启电脑,电脑启动的时候按住command+R;
2. 等画面上显示苹果logo的时候之后,你会看到「OS X 工具程式」的窗口,选择终端(注意,这里选择的时候要把触摸板按下去,而不是在触摸板上轻击);
3. 打开终端输入csrutil disable,输完之后重启;
4、重新选择上述两种方式安装即可(此处又有一坑我是重启后恢复系统原样所以之前的终端又被恢复了导致第一次安装直接失败,但是表紧,你再试一次就好了,估计是系统有缓存的原因吧)
安装成功的显示:
大功告成,开始你的mac tensorflow之旅吧!
验证下:
>>>import tensorflow as tf
>>>tf.__path__
成功输出安装地址就表示成功了