出现 CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate‘ 的解决方法

青旅半醒 2023-01-24 04:30 552阅读 0赞

目录

    1. 问题所示
    1. 原理分析
    1. 解决方法

1. 问题所示

在windows启动虚拟环境的时候:conda activate labelimg

出现如下问题:

  1. B:\>conda activate labelimg
  2. CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
  3. If using 'conda activate' from a batch script, change your
  4. invocation to 'CALL conda.bat activate'.
  5. To initialize your shell, run
  6. $ conda init <SHELL_NAME>
  7. Currently supported shells are:
  8. - bash
  9. - cmd.exe
  10. - fish
  11. - tcsh
  12. - xonsh
  13. - zsh
  14. - powershell
  15. See 'conda init --help' for more information and options.
  16. IMPORTANT: You may need to close and restart your shell after running 'conda init'.

截图如下所示:

在这里插入图片描述

2. 原理分析

大致意思为:

  1. shell没有正确配置为使用conda activate,要初始化shell,运行conda init <SHELL_NAME>
  2. 运行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的命令
所以无法执行

  1. 'souece' 不是内部或外部命令,也不是可运行的程序
  2. 或批处理文件。

截图如下:
在这里插入图片描述

发表评论

表情:
评论列表 (有 0 条评论,552人围观)

还没有评论,来说两句吧...

相关阅读