How to install Miniconda on ubuntu 22.04

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 通道一起使用。

安装

脚本

bash 复制代码
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

细节

bash 复制代码
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:~$

初始化

脚本

bash 复制代码
~/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中会添加如下内容

bash 复制代码
# >>> 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 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/lwk/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/home/lwk/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/lwk/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

我们重新打开一个终端窗口,就会正常使用conda命令了,如下所示:

bash 复制代码
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.

  COMMAND
    activate          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 Conda
    create            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:~$ 

查看一下版本号

bash 复制代码
lwk@qwfys:~$ conda --version
conda 24.1.2
lwk@qwfys:~$

卸载

脚本

bash 复制代码
conda init --reverse bash

细节

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:~$ 

参考文献

相关推荐
obullxl22 天前
大模型应用研发基础环境配置(Miniconda、Python、Jupyter Lab、Ollama等)
人工智能·python·ai·jupyter·miniconda·ollama
華小灼1 个月前
Python版本管理器-Miniconda
python·miniconda
dingdingfish1 个月前
安装MySQL Sample Database
mysql·database·sqldeveloper·install·employees
L小林同学4 个月前
mac解决brew install报错“fatal: not in a git directory“
git·python·macos·bash·pip·install·homebrew
Milton5 个月前
Miniconda 安装和使用笔记
miniconda
丰色木夕5 个月前
ubuntu快速安装miniconda
ubuntu·conda·miniconda
政安晨5 个月前
政安晨:政安晨:机器学习快速入门(三){pandas与scikit-learn} {模型验证及欠拟合与过拟合}
python·机器学习·pandas·scikit-learn·miniconda·模型验证·欠拟合与过拟合
代码讲故事6 个月前
git传输大文件时候安装git lfs install报错git: ‘lfs‘ is not a git command. See ‘git --help‘.
linux·git·错误·install·大文件·clone·lfs
政安晨6 个月前
政安晨的机器学习笔记——基于Ubuntu系统的Miniconda安装Jupyter Notebook
笔记·ubuntu·机器学习·jupyter·jupyternotebook·miniconda