How to install Miniconda on ubuntu 22.04
- 介绍
- 安装
- 脚本
- 细节
- 初始化
- 脚本
- 细节
- 卸载
- 脚本
- 细节
介绍
通常来说,要安装conda有以下三种安装方案:
- Miniconda
Miniconda 是 conda 的免费最小安装程序。它是 Anaconda 的一个小型引导版本,仅包含 conda、Python、它们都依赖的包以及少量其他有用的包(例如 pip、zlib 等)。
- Anaconda Distribution
Anaconda Distribution 是一个功能齐全的安装程序,附带一套用于数据科学的软件包,以及 Anaconda Navigator(一个用于 conda 环境的 GUI 应用程序)。
- Miniforge
Miniforge 是由 conda-forge 社区维护的安装程序,已预先配置为与 conda-forge 通道一起使用。
安装
脚本
mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh
细节
lwk@qwfys:~$ mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh
--2024-03-21 14:59:25-- https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
Resolving repo.anaconda.com (repo.anaconda.com)... 104.16.130.3, 104.16.131.3, 2606:4700::6810:8203, ...
Connecting to repo.anaconda.com (repo.anaconda.com)|104.16.130.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 144041912 (137M) [application/octet-stream]
Saving to: ‘/home/lwk/miniconda3/miniconda.sh’/home/lwk/miniconda3/miniconda.sh 100%[=====================================================================================================>] 137.37M 15.7MB/s in 19s 2024-03-21 14:59:45 (7.34 MB/s) - ‘/home/lwk/miniconda3/miniconda.sh’ saved [144041912/144041912]PREFIX=/home/lwk/miniconda3
Unpacking payload ...Installing base environment...Downloading and Extracting Packages:Downloading and Extracting Packages:Preparing transaction: done
Executing transaction: done
installation finished.
lwk@qwfys:~$
初始化
脚本
~/miniconda3/bin/conda init bash
细节
lwk@qwfys:~$ ~/miniconda3/bin/conda init bash
no change /home/lwk/miniconda3/condabin/conda
no change /home/lwk/miniconda3/bin/conda
no change /home/lwk/miniconda3/bin/conda-env
no change /home/lwk/miniconda3/bin/activate
no change /home/lwk/miniconda3/bin/deactivate
no change /home/lwk/miniconda3/etc/profile.d/conda.sh
no change /home/lwk/miniconda3/etc/fish/conf.d/conda.fish
no change /home/lwk/miniconda3/shell/condabin/Conda.psm1
no change /home/lwk/miniconda3/shell/condabin/conda-hook.ps1
no change /home/lwk/miniconda3/lib/python3.12/site-packages/xontrib/conda.xsh
no change /home/lwk/miniconda3/etc/profile.d/conda.csh
modified /home/lwk/.bashrc==> For changes to take effect, close and re-open your current shell. <==lwk@qwfys:~$
执行上述脚本以后,用户目录下的文件.bashrc中会添加如下内容
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/lwk/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; theneval "$__conda_setup"
elseif [ -f "/home/lwk/miniconda3/etc/profile.d/conda.sh" ]; then. "/home/lwk/miniconda3/etc/profile.d/conda.sh"elseexport PATH="/home/lwk/miniconda3/bin:$PATH"fi
fi
unset __conda_setup
# <<< conda initialize <<<
我们重新打开一个终端窗口,就会正常使用conda
命令了,如下所示:
lwk@qwfys:~$ conda
usage: conda [-h] [-v] [--no-plugins] [-V] COMMAND ...conda is a tool for managing and deploying applications, environments and packages.options:-h, --help Show this help message and exit.-v, --verbose Can be used multiple times. Once for detailed output, twice for INFO logging, thrice for DEBUG logging, four times for TRACE logging.--no-plugins Disable all plugins that are not built into conda.-V, --version Show the conda version number and exit.commands:The following built-in and plugins subcommands are available.COMMANDactivate Activate a conda environment.clean Remove unused packages and caches.compare Compare packages between conda environments.config Modify configuration values in .condarc.content-trust Signing and verification tools for Condacreate Create a new conda environment from a list of specified packages.deactivate Deactivate the current active conda environment.doctor Display a health report for your environment.info Display information about current conda install.init Initialize conda for shell interaction.install Install a list of packages into a specified conda environment.list List installed packages in a conda environment.notices Retrieve latest channel notifications.package Create low-level conda packages. (EXPERIMENTAL)remove (uninstall)Remove a list of packages from a specified conda environment.rename Rename an existing environment.repoquery Advanced search for repodata.run Run an executable in a conda environment.search Search for packages and display associated information using the MatchSpec format.update (upgrade) Update conda packages to the latest compatible version.
lwk@qwfys:~$
查看一下版本号
lwk@qwfys:~$ conda --version
conda 24.1.2
lwk@qwfys:~$
卸载
脚本
conda init --reverse bash
细节
lwk@qwfys:~$ conda init --reverse bash
no change /home/lwk/miniconda3/condabin/conda
no change /home/lwk/miniconda3/bin/conda
no change /home/lwk/miniconda3/bin/conda-env
no change /home/lwk/miniconda3/bin/activate
no change /home/lwk/miniconda3/bin/deactivate
no change /home/lwk/miniconda3/etc/profile.d/conda.sh
no change /home/lwk/miniconda3/etc/fish/conf.d/conda.fish
no change /home/lwk/miniconda3/shell/condabin/Conda.psm1
no change /home/lwk/miniconda3/shell/condabin/conda-hook.ps1
no change /home/lwk/miniconda3/lib/python3.12/site-packages/xontrib/conda.xsh
no change /home/lwk/miniconda3/etc/profile.d/conda.csh
modified /home/lwk/.bashrc==> For changes to take effect, close and re-open your current shell. <==lwk@qwfys:~$
参考文献
- Miniconda / Quick command line install
- Installing conda