直接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’ 命令。

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐