1.问题描述:
conda激活虚拟环境时,出现如下错误:
conda activate base
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
2.解决方法
这里以初始化bash
类型的shell命令为例说明,步骤如下:
- 执行命令
conda init bash
; - 新开一个窗口,执行
conda activate [虚拟环境xxx-env]
; - 若还是出现上述错误,则按照以下步骤进行解决:
- (1)执行
source activate
; - (2)执行
source deactivate
;(若提示命令过期,可用conda deactivate
) - (3)执行
conda activate [虚拟环境xxx-env]
。
- (1)执行
**注意:**也可将命令(1)和(2)加入到~/.bashrc文件中,每次启动控制台时自动执行。