https://docs.conda.io/projects/conda/en/stable/

Quick command line install

These quick command line instructions will get you set up quickly with the latest Miniconda installer. For graphical installer (.exe and .pkg) and hash checking instructions, see Installing Miniconda.

These four commands quickly and quietly install the latest M1 macOS version of the installer and then clean up after themselves. To install a different version or architecture of Miniconda for macOS, change the name of the .sh installer in the curl command.

mkdir -p ~/miniconda3
curl [<https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh>](<https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh>) -o ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh

After installing, initialize your newly-installed Miniconda. The following commands initialize for bash and zsh shells:

~/miniconda3/bin/conda init bash
~/miniconda3/bin/conda init zsh

Conda 使用

conda 是一个流行的包管理器,主要用于管理 Python 包和环境,特别是在数据科学和机器学习领域。以下是如何使用 conda 的基本指南:

  1. 安装 conda: conda 主要通过安装 Anaconda 或 Miniconda 来获得。

  2. 创建新的环境:

    conda create --name myenv python=3.8
    

    这将创建一个名为 myenv 的新环境,并安装 Python 3.8。

  3. 激活环境:

  4. 安装包:

    conda install numpy pandas matplotlib
    
    

    这将在当前激活的环境中安装 numpypandasmatplotlib

  5. 查看已安装的包:

    conda list
    
    
  6. 更新包:

    conda update numpy
    
    
  7. 卸载包:

    conda remove numpy
    
    
  8. 创建环境的克隆:

    conda create --name myclone --clone myenv
    
    
  9. 导出环境为 YAML 文件:

    conda env export > environment.yml
    
    

    这将使得他人可以复制你的环境。

  10. 从 YAML 文件创建环境:

    conda env create -f environment.yml