conda activate xxx-env出现错误CommandNotFoundError

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)和(2)加入到~/.bashrc文件中,每次启动控制台时自动执行。

3.Conda创建虚拟环境参考链接

https://cloud.tencent.com/developer/article/2322439

猜你喜欢

转载自blog.csdn.net/m624197265/article/details/137566496