mac anaconda 虚拟环境安装 tensorflow==1.14.0

1,751 阅读1分钟

1.创建虚拟环境 tf

    conda create --name tf python=3.6

2.激活进行 tf

conda activate tf

3.安装 tensorflow

conda install tensorflow==1.14.0

这里需要注意的是版本,mac 可能不支持这么高的版本,直接安装 tensorflow==1.5 成功率可能更高。

之前我是用 pip 安装 tensorflow ,但是虽然成功安装,import 的时候总是会报错,所以就改用 conda 安装了

4.在 python 环境中导入 tensorflow 报错如下

import tensorflow
/Users/wys/opt/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/Users/wys/opt/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
   。。。
  

需要安装新的 numpy

pip3 install numpy==1.16.4

5. python 环境中重新导入 tensorflow 成功