Hitomi's Note

瞳の笔记

Anaconda 安装使用简明教程

发布于|# 软件# Python

由于越来越多的包对 Python 版本做出要求,而不同 Python 版本的切换使用官方工具非常麻烦。Anaconda 使用了虚拟环境,只要切换环境就可以自动实现版本切换。

  1. 卸载系统里的所有 Python 版本。

  2. 安装

    Anaconda3-2020.11-Windows-x86_64.exe

    下载,如果不用 cmd ,或者常用 Powershell 及 Windows Terminal ,可以不勾选 Add Anaconda3 to the system PATH environment variable 。建议不勾。

  3. 设置国内源

    1. 开始菜单 –> Anaconda3 –>Anaconda Powershell Prompt (anaconda3),打开命令窗口。

    2. 执行

      conda config --set show_channel_urls yes
    3. 修改 C:\Users\用户名\.condarc

    4. 复制粘贴以下内容覆盖全部。

      channels:
        - defaults
      show_channel_urls: true
      default_channels:
        - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
        - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
        - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
      custom_channels:
        conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
        msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
        bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
        menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
        pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
        simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  4. 设置 Powershell

    在开始菜单中打开 Anaconda Powershell Prompt (Anaconda3),输入 conda init powershell ,重新打开 Powershell 即可。

  5. 测试

    conda create -n py38 python==3.8.1

    如果可以使用,环境会自动创建。通过 conda activate py38 激活环境。

  6. VS Code 可以自动识别环境名和版本号。