HR's Blog

Swimming 🏊 in the sea🌊of code!

0%

极简安装Conda

.

以下用Shell方式来安装Conda,除了Mac,该方法也适用于Linux系统。

Step 1

下载sh文件
官方安装脚本下载
找到新版的Miniconda版本,下载最新的的sh文件,例如Mac端:
Miniconda3-py39_4.9.2-MacOSX-x86_64.sh

直接下载最新版的miniconda:

1
2
3
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-armv7l.sh
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh

Step 2

执行sh文件
Miniconda:

1
bash Miniconda3-py39_4.9.2-MacOSX-x86_64.sh

Step3

配置bash文件, 安装好Conda以后默认是无法找到该命令的,这时候需要我们初始化。

1
2
 ~/Desktop  conda
zsh: command not found: conda

当然你也可以手动添加环境参数,最省事的办法就是运行conda init,让conda给你配置。如果没有修改conda的安装路径,默认在/Users/<#User Folder#>/miniconda3,找到bin目录下的conda命令,手动调用init方法,这时候conda会帮你配置好所有的环境,重启Shell会生效。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
✘  ~/miniconda3/condabin  ./conda init
no change /Users/Huanrong/miniconda3/condabin/conda
no change /Users/Huanrong/miniconda3/bin/conda
no change /Users/Huanrong/miniconda3/bin/conda-env
no change /Users/Huanrong/miniconda3/bin/activate
no change /Users/Huanrong/miniconda3/bin/deactivate
no change /Users/Huanrong/miniconda3/etc/profile.d/conda.sh
no change /Users/Huanrong/miniconda3/etc/fish/conf.d/conda.fish
no change /Users/Huanrong/miniconda3/shell/condabin/Conda.psm1
no change /Users/Huanrong/miniconda3/shell/condabin/conda-hook.ps1
no change /Users/Huanrong/miniconda3/lib/python3.9/site-packages/xontrib/conda.xsh
no change /Users/Huanrong/miniconda3/etc/profile.d/conda.csh
modified /Users/Huanrong/.bash_profile

==> For changes to take effect, close and re-open your current shell. <==

重启Shell,可以看到熟悉的(Base)出来了,这时候你就可以正常使用Conda了。