Linux(包括WSL)安装Miniconda教程
首先确保已经阅读过Windows安装Miniconda教程(以下简称Windows篇)。有的内容不再赘述。
本教程适用于Linux平台,包括Windows Subsystem for Linux(WSL),下面是具体步骤。此方法亦可用于macOS命令行安装,注意下载对应文件即可。
下载和安装
同样,从镜像站点找到文件,但不用直接下载。
清华大学镜像:https://mirrors.tuna.tsinghua.edu.cn/anaconda/
中国科技大学镜像:https://mirrors.ustc.edu.cn/anaconda/
我们访问后点开其中的miniconda
目录,其中大多数文件都是以Miniconda3-<Python版本>_<版本>-<系统>-<架构>
来命名的。不知道选择什么版本,就找到最新版,其命名是Miniconda3-latest-<系统>-<架构>
,比如下面示例的就是Miniconda3-latest-Linux-x86_64.sh
,对应x86-64架构的Linux系统。
打开Linux的终端,输入如下命令安装,这里使用的是清华大学镜像,请自行替换成需要的镜像地址。
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash ./Miniconda3-latest-Linux-x86_64.sh
注意是两条命令分别输入和回车执行。wget
是下载文件,bash
是执行shell脚本。wget
这条命令也可以用curl
命令来代替(如下),根据自己的系统和喜好选择。
curl -O https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh
执行后,首先会提示查看授权协议(如下),按回车>>>
是提示符,表示此时需要用户输入。
Welcome to Miniconda3 py313_25.3.1-1
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
回车几次后,会提示是否接受协议(如下),输入yes
后回车接受即可。
Do you accept the license terms? [yes|no]
>>>
然后会确认安装目录(如下),默认是用户的家目录,如果没有特殊需求,直接回车确认即可。
Miniconda3 will now be installed into this location:
/home/qakcn/miniconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/home/qakcn/miniconda3] >>>
最后,会提示是否注入当前shell(如下),如无特殊需求直接yes
后回车确认即可。
Do you wish to update your shell profile to automatically initialize conda?
This will activate conda on startup and change the command prompt when activated.
If you'd prefer that conda's base environment not be activated on startup,
run the following command when conda is activated:
conda config --set auto_activate_base false
You can undo this by running `conda init --reverse $SHELL`? [yes|no]
[no] >>>
关闭终端再打开,就可以看到出现(base)
提示所处的虚拟环境为基础环境,此时就安装完成了。
安装后配置
.condarc
配置
直接使用文本编辑器打开~/.condarc
即可,这里使用的是vim
。
vim ~/.condarc
内容和Windows篇中的一样,此处不再赘述。
Oh My Zsh兼容性设置
如果使用zsh
作为shell并且使用了Oh My Zsh作为配置框架,会出现两个当前虚拟环境的提示符。
我们只要关闭Miniconda修改提示符的行为就行了,打开终端执行如下命令即可:
conda config --set changeps1 false
卸载
要卸载Miniconda3,首先还是打开终端。然后要反激活基础环境,确保所处环境提示是base
,然后执行如下命令:
conda deactivate
然后直接执行安装目录下的uninstall.sh
(下面是没有修改过安装位置的情况,如果修改过请替换为实际位置)。
~/miniconda3/uninstall.sh
接着会询问是否卸载(如下),输入yes
后回车继续。
Are you sure you want to remove /home/qakcn/miniconda3 and all of its contents?
[no] >>>
等待卸载完成即可。
赞赏微信赞赏
支付宝赞赏