Mac 安装tensorflow
🕧 by pyList at 2018-12-20 11:51
python 环境。在Mac 系统上实行 pip install tensorflow
可能会出现下面的错误提示
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.
是尝试卸载numpy
时出现的错误,可用下面一行强行(忽略旧版本升级)安装新的numpy
sudo pip install --ignore-installed numpy
或者配合Homebrew 安装,这是官方文档提的方法:
安装python
$ brew install python
$ brew linkapps python
$ which python
/usr/local/bin/python
用 easy_install 安装或升级pip:
$ easy_install pip
$ pip install --upgrade pip
安装 TensorFlow:
$ pip install tensorflow
$ pip install tensorflow-gpu # Optional
测试:
$ python
>>> import tensorflow as tf
如果上面的方法安装不成功,可尝试下面一行解决,填写最新版本:
pip install tensorflow==1.12.0 --user
关于python版本的问题
#当需要输入python时直接指向python3.5,可以这样处理:
ln -s /usr/local/python3/bin/python3 /usr/bin/python #前面换成你的安装路径
#ps:如果提示 ln: creating symbolic link `/usr/bin/python': File exists
#需要把原来的/usr/bin/python 通过以下命令备份一下
mv /usr/bin/python /usr/bin/python.bak
#需要恢复原来的python指向的话:
cp /usr/bin/python.bak /usr/bin/python
python3
如果是python3 环境就更方便,但目前tensorflow 只支持 Python 3.4, 3.5, 3.6
,如果用brew install python
或 brew install python3
则会安装最新的python3.7,用下面的方法才能安装python3.6 :
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
此时默认已安装pip3
,更新
pip3 install --upgrade pip
安装tensorflow
sudo pip3 install tensorflow
成功安装的包:
$ pip3 list
Package Version
------------------- -------
absl-py 0.6.1
astor 0.7.1
gast 0.2.0
grpcio 1.17.1
h5py 2.8.0
Keras-Applications 1.0.6
Keras-Preprocessing 1.0.5
Markdown 3.0.1
numpy 1.15.4
pip 18.1
protobuf 3.6.1
setuptools 39.2.0
six 1.12.0
tensorboard 1.12.1
tensorflow 1.12.0
termcolor 1.1.0
Werkzeug 0.14.1
wheel 0.31.1
看看tensorflow 的信息:
$ pip show tensorflow
Name: tensorflow
Version: 1.12.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Location: /usr/local/lib/python3.6/site-packages
Requires: six, termcolor, tensorboard, numpy, keras-preprocessing, keras-applications, grpcio, wheel, protobuf, absl-py, astor, gast
Required-by:
测试:
python3 -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
输出:
tf.Tensor(-193.46434, shape=(), dtype=float32)
本文网址: https://pylist.com/t/1545277904 (转载注明出处)
如果你有任何建议或疑问可以在下面 留言
发表第一条评论!
相关推荐
小工具
标签
mac
lua
极速
简洁
安装
app
store
登录
未知
pip2
pip3
共存
files
open
解决
办法
socks5
代理
依赖
使用
自动更新
microsoft
关闭
系统启动
usb
ubuntu
debian
u盘
diskutil
格式化
顽固
gnu
linux
python
解析
电子书
信息
文件
wkwebview
ios
载入
灵活
bbr
openwrt
路由
开启
cjson
module
错误
国内
golang
md5
计算
os
popen
超时
老旧
服务器
笔记本
改造
记录
低功耗
web
爬虫
组装
nginx
上传
中断
默认值
struct
设置
之坑
服务
google
身份验证
authenticator
迁移
手机
webdriver
微博
selenium
硬件加速
ubnt
er
固件
静音
风扇
主机
微信
尝鲜
视频
体验
cpu
查看
温度
chrome
server
浏览
编译
宅家
坑记
屏幕
动手
quic
抢先
useragent
搜索引擎
蜘蛛
真假
识别
最近发表
- Mac 关闭 Microsoft 自动更新
- Mac 登录 App Store 出现“发生了未知错误”的解决方法
- 老笔记本改造为无风扇静音主机方案
- 自己组装21瓦低功耗家庭爬虫、文件、web服务器
- 微信视频号尝鲜体验
- Ubuntu/Debian 查看CPU温度的方法
- 在Ubuntu/debian Server 系统使用Chrome 无头浏览模式
- 换手机后 Google 身份验证器 Google Authenticator 数据迁移的简单方法
- 使用Golang selenium WebDriver 自动登录微博
- 在 Ubuntu 或其它 GNU/Linux 系统下安装 Debian
- Mac 下制作 USB ubuntu/debian 系统启动、安装盘的几种方法
- ubuntu/debian 下自行编译 OpenWRT 固件
- 宅家自己动手换手机屏幕掉坑记
- 路由 UBNT ER-X 官方固件升级及开启硬件加速的方法
- 在 Nginx 和 Golang web 上抢先体验 QUIC
- 从UserAgent识别搜索引擎并判断真假蜘蛛
最近浏览
- python 解析电子书的信息
- 在终端使用Mac diskutil 命令格式化顽固U盘
- IOS WKWebView 灵活载入本地文件和网络文件
- Openwrt 路由上开启BBR
- 出现 lua module 'cjson' not found 错误的解决方法
- OpenWrt 国内源
- golang 计算大文件md5
- python 解决os.popen 超时问题
- 把老旧笔记本改造为家庭服务器过程记录
- 自己组装21瓦低功耗家庭爬虫、文件、web服务器
- Nginx 服务器上传大文件经常中断的解决方法
- go struct 设置默认值
- Golang 服务之坑:too many open files
- 换手机后 Google 身份验证器 Google Authenticator 数据迁移的简单方法
- 使用Golang selenium WebDriver 自动登录微博
- 路由 UBNT ER-X 官方固件升级及开启硬件加速的方法