最新 Mac 安装python+anaconda+tensorflow,pytorch 全步骤
版本
“从一个什么都没安装的mac开始!下面的代码都是直接输入在 >_ 终端里”
安装anaconda会直接附带安装python
吴恩达的DL课用的是tensorflow. 1.x版本 配套版本 tf1.15.0+python3.7+anaconda 1.7.2(如想下载tf2.X请自行查看匹配版本)
可以直接官网下载anaconda,官网2020.07更新的anaconda是用python3.8的,还得单独为tf创建python3.7的环境
最好下载历史版本,选择2020.02版本
anaconda官网链接:https://www.anaconda.com/products/individual
历史版本链接:https://repo.anaconda.com/archive/
查看版本命令
anaconda -V
一. 正常情况三步安装
按照上述下载好anaconda
- 创建tensorflow环境
#创建一个名为tensorflow的环境
conda create -n tensorflow python=3.7
- 激活环境
conda activate tensorflow
- 安装tensorflow
pip install tensorflow==1.15.0
测试是否成功
(tensorflow) xxxxx@xxxxxxMacBook-Pro ~ % python3
Python 3.7.7 (default, May 6 2020, 04:59:01)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>>
没有报错就成功啦
安装pytorch 同理
pip命令换一下,去官网按照自己的情况查找命令:https://pytorch.org/get-started/locally/
二. 第二步/第三步超时
显示错误如下:
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out.
添加镜像
创建环境(即正常安装的第二步)添加如下镜像后成功
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
pip tf(即正常安装的第三步)添加如下镜像后成功
pip install tensorflow==1.15.0 -i https://mirrors.aliyun.com/pypi/simple/
按照我的理解上面的上面是永久镜像,上面是仅这条命令用镜像,阿里云可以的!
不行删掉原本镜像试试下面其他的,人生秘诀就是:永远相信总会成功的!
#清华镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
#中科大镜像
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
conda config --set show_channel_urls yes
三. zsh:conmmand not found
因为觉得是anaconda问题,想卸载了重新安,直接拖文件夹删除,或者安装过很多次是不行的。出现了标题这种情况 ,查了很多博客,最后是下面这篇解决的
https://blog.csdn.net/weixin_43870127/article/details/104790123
四.jupyter notebook 改变打开的默认路径
- 终端输入
jupyter notebook --generate-config
- 进入访达里面的
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)