CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
Window10 cmd命令行下运行 conda activate xxx后出错
C:\Windows\system32>conda activate ML-tf2
报错内容如下:
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 <SHELL_NAME>
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’.
简单处理
使用错误中提醒的
C:\Windows\system32>CALL conda.bat activate
可以成功激活,但是有没有更简单的方法
错误分析
环境变量已经添加
但是运行conda activate 无法激活我们所需要的虚拟环境
且使用管理员身份运行cmd 也无法解决问题
在环境变量地址:\anaconda\Scripts 下发现只有activate.bat文件
遂直接输入activate + 虚拟环境名
C:\Windows\system32>activate ML-tf2
(ML-tf2) C:\Windows\system32>
成功
后续发现
上面使用activate激活了我们的虚拟环境以后,再次激活便可以使用:
C:\Windows\system32>conda activate ML-tf2
但是关掉这个cmd对话框。新开一个cmd,第一次激活的时候,还需要用activate+虚拟环境 进行激活