禁止Conda默认进入base环境

问题介绍

安装anaconda后取消命令行前出现的base,取消每次启动自动激活conda的基础环境。

造成原因

conda默认设置。

解决方案

  1. 方法一:
    • 每次通过进入命令行后通过conda deactivate退出base环境回到系统自动的环境
  2. 方法二
    • 希望在启动时不激活condabase环境,通过将auto_activate_base参数设置为falseconda config --set auto_activate_base false
    • 那要进入的话通过conda activate base
    • 如果反悔了,还是希望base一直留着,通过conda config --set auto_activate_base true来恢复

文档建议

有一种更合适的方法,就是直接取消conda默认的显示环境的设置,如下所述:

To simply return to the base environment, it’s better to call conda activate with no environment specified, rather than to try to deactivate. If you run conda deactivate from your base environment, you may lose the ability to run conda at all. Don’t worry, that’s local to this shell - you can start a new one. By default, the command prompt is set to show the name of the active environment. To disable this option:

  1. conda config --set changeps1 false

To re-enable this option:

conda config --set changeps1 true

参考链接