Miniconda

7 阅读1分钟

简介

Miniconda is a free minimal installer for conda. It is a small, bootstrap version of Anaconda that includes only conda, Python, the packages they depend on, and a small number of other useful packages, including pip, zlib and a few others. Use the conda install command to install 720+ additional conda packages from the Anaconda repository.

配置环境变量

  • %conda%
  • %conda%\Scripts
  • %conda%\Library\bin

换源

Windows用户无法直接创建名为.condarc的文件,可先执行conda config --set show_channel_urls yes生成该文件之后再修改。

channels:
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/bioconda/
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/free/
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/pytorch/
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
  - defaults
show_channel_urls: true

也可以使用conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/直接添加。 如果需要换回默认源,直接使用conda config --remove-key channels删除channels即可。

常用命令

  • 版本和帮助信息
    • 查看版本:conda -Vconda --version  
    • 获取帮助:conda -hconda --help
    • 相关信息:conda list 
  • 虚拟环境管理 - 显示所有虚拟环境:conda env list  - 创建虚拟环境:conda create --name py37  - 指定Python版本创建虚拟环境:conda create --name py37 python=3.7 - 指定Python版本创建虚拟环境并安装指定依赖项:conda create --name py37 python=3.7 numpy pandas - 通过克隆现有虚拟环境的方式创建虚拟环境:conda create --name py372 --clone py37 - 分享虚拟环境并重定向到指定的文件中:conda env export > environment.yml - 通过分享的虚拟环境文件创建虚拟环境:conda env create -f environment.yml  - 激活虚拟环境:conda activate py37  - 退出虚拟环境:conda deactivate  - 删除虚拟环境:conda remove --name py37 --all 
  • 包管理 - 搜索指定的包:conda search matplotlib  - 安装指定的包:conda install matplotlib - 更新指定的包:conda update matplotlib - 移除指定的包:conda remove matplotlib