使用conda在mac系统上安装Tensorflow
- 安装anaconda2,之前与mac系统自带的python的2.7环境相兼容,后创建python3.6.8 环境安装tensorflow
- 创建虚拟环境
$ conda create -n tensorflow pip python=3.6
- 激活虚拟环境
$ source activate tensorflow
也可以用
$ conda activate tensorflow
激活虚拟环境时使用conda和source命令均可,但返回原来的环境只能使用conda(?)
$ conda deactivate
- 安装jupyter notebook
$ pip install jupyter notebook
这一步需要在tensorflow前安装,否则在jupyter notebook上使用tensorflow会上报no module named tensorflow. 参考博客link重新安装ipython和jupyter后报错jupyter notebook kernel restart fail,参考博客link先卸载ipykernel后重新安装ipykernel。此解决了jupyter notebook kernel restart fail的问题,但仍报no module named tensorflow。
解决方案:删除原有环境 ,先安装jupyter notebook后安装tensorflow,问题解决,但原因未知。
conda remove --name tensorflow --all
打开jupyter notebook后出404 not found的问题,参考博客link后解决。
5. 安装tensorflow
(tensorflow)$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl
安装结束,能够正常在jupyter notebook上导入tensorflow。