基于MacBook、Python 3.6 环境的tensorflow安装
前提条件:python / pip (用来安装和管理以 Python 编写的软件包)
- python 2.7 + pip
- python 3.n + pip3
在终端输入以下代码安装最新版本的tensorflow
$ pip3 install tensorflow
如果失败,则参考以下代码
$ sudo pip3 install --upgrade https://download.tensorflow.google.cn/mac/cpu/tensorflow-1.8.0-py3-none-any.whl
如果网络连接失败则将URL的网址部分替换为清华镜像
$ sudo pip3 install --upgrade https:// https://mirrors.tuna.tsinghua.edu.cn/mac/cpu/tensorflow-1.3.0-py3-none-any.whl
安装成功后终端输入python进入编程后输入以下代码进行测试
import tensorflow as tf
tf.__version__
exit()
在我的环境里出现numpy跟不上最新版本的tensorflow的情况,我决定同步更新numpy
$ pip3 install -U numpy
然后就可以成功运行测试代码了
但是!!!出现了两个Warning
RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6
原因是版本不匹配
解决方法:
$ pip3 install tf-nightly
warning消失,但是tensorflow的版本也不同了,暂时不知道有没有影响。
FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
原因是h5py包内出错
解决方法:更新h5py包
$ pip3 install h5py==2.8.0rc1