卸载 Anaconda Distribution#

需要卸载 Anaconda Navigator?

请参阅卸载 Navigator

需要卸载 Miniconda?

此页面上的卸载说明与 Miniconda 的卸载说明几乎相同,但有关 Miniconda 的具体卸载说明,请参阅卸载 Miniconda

注意

卸载过程可能会留下某些项目,例如桌面快捷方式或补充文件,完成后必须手动删除这些项目。这是一个正在解决的已知问题。

要卸载 Anaconda 安装:

  1. (可选)如果您在anaconda3目录中,您可以手动删除它们以增加计算机上的可用磁盘空间。此步骤必须在卸载 Anaconda Distribution 之前执行。

    卸载anaconda3目录
    1. 打开 Anaconda Prompt。

    2. 通过运行以下命令查看所有环境的列表:

      conda info --envs
      

      如果您在anaconda3,您将需要卸载包含环境的目录。使用以下命令卸载目录将删除环境文件并取消注册环境。

    3. 打开您喜欢的 shell。

    4. 通过运行以下命令卸载目录:

      # Replace <YOUR_USERNAME> with your Windows username
      # Replace <PATH_TO_ENV_DIRECTORY> with the path to the directory that contains the environments
      C:\Users\<YOUR_USERNAME>\anaconda3\_conda constructor uninstall --prefix <PATH_TO_ENV_DIRECTORY>
      
  2. 在 Windows 搜索框中搜索“控制面板”,然后选择控制面板应用程序。

  3. 单击 Programs 下的 Uninstall a program

  4. 从程序列表中选择 Anaconda。

  5. 单击 Uninstall(卸载)。

  6. 按照屏幕上的说明完成卸载过程。

静默 CLI 卸载

在 Windows作系统上,您可以使用命令提示符或 PowerShell 静默卸载 Anaconda Distribution。

打开一个新的命令提示符窗口并运行以下命令:

start /wait .\anaconda3\Uninstall-Anaconda3.exe /S

打开一个新的 PowerShell 窗口并运行以下命令:

Start-Process -FilePath ".\anaconda3\Uninstall-Anaconda3.exe" -ArgumentList "/S" -Wait

注意

卸载 Anaconda Distribution 可能需要几分钟才能完成。

  1. 打开您的终端应用程序。

  2. (可选)如果您在anaconda3目录中,您可以手动删除它们以增加计算机上的可用磁盘空间。此步骤必须在卸载 Anaconda Distribution 之前执行。

    卸载anaconda3目录
    1. 通过运行以下命令查看所有环境的列表:

      conda info --envs
      

      如果您在anaconda3,您将需要卸载包含环境的目录。使用以下命令卸载目录将删除环境文件并取消注册环境。

    2. 通过运行以下命令卸载目录:

      # Replace <PATH_TO_ENV_DIRECTORY> with the path to the directory that contains the environments
      ~/anaconda3/_conda constructor uninstall --prefix <PATH_TO_ENV_DIRECTORY>
      
  3. (可选)通过运行以下命令,从所有终端 shell 配置文件中删除任何 conda 初始化脚本:

    conda activate
    conda init --reverse --all
    
    什么是 conda 初始化脚本?

    初始化脚本执行命令,将 shell 配置为自动识别 conda 命令。

    有关初始化的技术说明,请参阅 conda 官方文档中的 Conda 初始化

    要查看可以初始化 conda 的 shell 列表,请参阅 conda 官方文档中的 conda init

  4. 删除整个anaconda3目录替换为rm -rf.根据您的安装,此目录将位于您的根文件夹或 opt 文件夹中。

    警告

    -r(递归)标志、f(force) 标志会删除所有指定的目录及其中的文件,而不提示您进行确认。在运行之前,请仔细检查并验证是否已正确指定要删除的目录rm -rf,因为此作无法撤消。

    # The following are a few examples of how you might need to delete your anaconda3 folder
    rm -rf anaconda3
    rm -rf ~/anaconda3
    sudo rm -rf /opt/anaconda3
    
  5. (可选)移除隐藏的.condarcfile 和.conda,.continuum.anaconda目录:

    谨慎

    考虑保留.condarc文件,特别是如果您拥有 conda 的自定义配置并计划重新安装。

    rm -rf ~/.condarc ~/.conda ~/.continuum ~/.anaconda
    
  6. 关闭并重新打开您的终端以刷新它。您应该不会再看到(base)在终端提示符中。