macbook air怎么安装python_mac 安装tensorflow

mac上默认装有python,先看一下python的版本,

a587edd8854a

image.png

python3 以上的版本默认有pip ,所以2.7需要手动安装pip,安装命令

sudo easy_install pip

a587edd8854a

image.png

a587edd8854a

image.png

tensorflow1.2以上版本macos上不支持gpu,现在tensorflow1.8已经发布了。

安装cpu版本:

pip install tensorflow

a587edd8854a

image.png

失败了:

Collecting html5lib==0.9999999 (from tensorboard<1.9.0,>=1.8.0->tensorflow)

Using cached https://files.pythonhosted.org/packages/ae/ae/bcb60402c60932b32dfaf19bb53870b29eda2cd17551ba5639219fb5ebf9/html5lib-0.9999999.tar.gz

matplotlib 1.3.1 requires nose, which is not installed.

matplotlib 1.3.1 requires tornado, which is not installed.

Installing collected packages: numpy, pbr, funcsigs, six, mock, enum34, wheel, astor, backports.weakref, termcolor, gast, protobuf, futures, grpcio, absl-py, markdown, html5lib, bleach, werkzeug, tensorboard, tensorflow

Found existing installation: numpy 1.8.0rc1

Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

sniper:~ chris$ cd /usr/lib/python2.7/

貌似少一些依赖关系、还有不兼容的问题

先执行两命令看看

sudo easy_install nose

sudo easy_install tornado

a587edd8854a

image.png

再解决兼容问题:

在终端运行:

sudo pip install --ignore-installed numpy

a587edd8854a

image.png

完成后运行

pip install tensorflow

a587edd8854a

image.png

执行

pip install --user tensorflow

a587edd8854a

image.png

按照错误提示命令执行,但是依然会报错 ,原因是没有权限.

所以执行:

sudo pip install --upgrade pip

a587edd8854a

image.png

最后再执行

pip install --user tensorflow

验证一下:

import tensorflow as tf

hello=tf.constant("hello tensorflow")

sess=tf.Session()

print(sess.run(hello))

没毛病

a587edd8854a

image.png

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值