出现 CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate‘ 的解决方法
目录
- 问题所示
- 原理分析
- 解决方法
1. 问题所示
在windows启动虚拟环境的时候:conda activate labelimg
出现如下问题:
B:\>conda activate labelimg
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'.
截图如下所示:
2. 原理分析
大致意思为:
- shell没有正确配置为使用
conda activate
,要初始化shell,运行conda init <SHELL_NAME>
- 运行
conda init
后,需要关闭并重新启动shell
3. 解决方法
按照上方的提示进行初始化:conda init bash
截图如下:
将其终端关闭之后,通过cmd打开另外一个终端进行测试:conda activate 你的虚拟环境名
到这一步如果还不行 (根据不同操作系统执行不同命令激活)
- linux操作系统:
1.通过source 激活该虚拟环境:source activate 你的虚拟环境名
2.再次退出:conda deactivate
3.之后可正常使用:conda activate 你的虚拟环境名
- windows操作系统:
1.通过activate激活该虚拟环境:activate 你的虚拟环境名
2.再次退出:conda deactivate
3.使用conda进入虚拟环境:conda activate 你的虚拟环境名
补充:
source 不是window的命令
所以无法执行
'souece' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
截图如下:
还没有评论,来说两句吧...