mac下安装TensorFlow

来源:互联网 发布:淘宝被关闭了怎么激活 编辑:程序博客网 时间:2024/06/06 15:49

安装步骤:

https://www.tensorflow.org/install/install_mac

参考文章:

http://blog.csdn.net/a595130080/article/details/55506237


碰到的问题:

1:numpy问题,运行tensorFlow hello程序报错:module compiled against API version 0xa but this version of numpy is 0x9

  numpy版本问题,这是由于mac内置的numpy是1.8.0,tensorflow需要numpy1.11.0版本

  numpy是python用来进行矩阵运算的计算包,Mac系统自带的Python是2.7版本,包含了0.8版本的numpy,导致引入Tensorflow的时候报错。


  使用pip命令安装的numpy是存放在sie-package下边,而自带的numpy在extra目录下面。系统自带的Python会调用extra目录下的numpy。


有以下几种方案来解决

a、更改参数路径,让Python调用sie-package下边的numpy



b、删掉或者更改系统自带的numpy(验证有效)

sudo mv /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy_old

    如果不能执行命令的话,请在mac上关闭sip.

关闭sip特性

1)重启 MAC ,在重启的过程中按住 Command+R,进入安全模式

2)在顶部的菜单栏中打开终端 ,输入csrutil disable 命令关闭 SIP 安全特性(想要在开启sip的话就用csrutil enable命令即可)

3)重启MAC就OK了


c、升级系统自带的numpy


2.TensorFlow1.0 运行报错 AttributeError: type object 'NewBase' has no attribute 'is_abstract'


   这个问题是由six模块导致的,原因和numpy一样。


   可用同样的办法解决:


sudo mv /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy_old

sudo mv /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy_old/ /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy


   



原创粉丝点击