通过git bash激活虚拟环境遇到的问题

直接git bash后用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 <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’.

解决如下:
错误信息的含义:

错误信息首先告诉你,你的 shell 还没有被正确配置以使用 ‘conda activate’ 命令。
如果你正在使用批处理脚本 (batch script),它建议你将调用 ‘conda.bat activate’ 而不是 ‘conda activate’。

解决方法:
首先,你需要运行 ‘conda init’ 命令,以初始化你的 shell。你需要将 “<SHELL_NAME>” 替换为你实际使用的 shell 的名称。通常情况下,支持的 shell 包括 bash、cmd.exe、fish、tcsh、xonsh、zsh 和 powershell。
例如,如果你使用的是 bash,你可以运行以下命令:
$ conda init bash
运行 ‘conda init’ 命令后,它会自动配置你的 shell 以正确使用 ‘conda activate’。
重要注意事项:

最后,错误信息还提醒你可能需要关闭并重新启动你的 shell,以确保配置的更改生效。在执行 ‘conda init’ 后,重新启动 shell 可能是必要的。

总之,这个错误是由于 Conda 环境配置问题引起的,通过运行 ‘conda init’ 并遵循相应的提示来配置你的 shell,你应该能够解决这个问题并正确使用 ‘conda activate’ 命令。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值