CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate‘. If using

用 Anaconda的指令 conda activate 遇到了错误提示。

CommandNotFoundError: Your shell has not been properly configured to
use ‘conda activate’. If using ‘conda activate’ from a batch script,
change your invocation to ‘CALL conda.bat activate’.

To initialize your shell, run

$ conda init 

Currently supported shells are:

  • bash
  • cmd.exe
  • 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’.

前前后后查了很多方法,试过conda init cmd.exe 、source activate、试过配置多两个环境。最终在一篇关于vscode teminal powershell 的文章中找到解决方案。

解决方案

步骤一:
在Anaconda powershell prompt 中执行

conda init powershell

后,关闭Anaconda powershell prompt。

在这里插入图片描述
步骤二:
ctrl + R 打开windows10运行界面,输入powershell 回车,并在powershell 界面输入命令

set-ExecutionPolicy RemoteSigned

此时,系统会弹出一些提示,这时候输入

Y

回车,操作如下图所示。

CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate‘. If using_第1张图片
CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate‘. If using_第2张图片
步骤三:
重启 Anaconda powershell prompt,输入命令
conda activate [虚拟环境名称],比如我的

conda activate py36

就可以激活想要的环境了。

**

参考

**
http://nicethemes.cn/news/txtlist_i6705v.html

你可能感兴趣的:(python,anaconda,python,windows,anaconda,cmd,powershell)