我想在bash.exe上使用" conda activate",因为我将其设置为vscode默认终端。当F5调试运行时,使用此方法。
系统
- Windows 10
- 视觉工作室代码1.36.1
-Conda 4.7.10
- Windows v2.22.0
环境变量由Anaconda安装管理器设置,python
命令在任何情况下工作。但是conda activate
没有。此命令在新的bash.exe中失败,下面的错误。
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'.
conda activate
仅在以下情况下运行良好:
1.在git-bash.exe上
2.打开bash.exe,然后通过exec $SHELL -l
重新启动外壳,然后`conda activate'
关于1。,为什么git-berash.exe和bash.exe之间存在如此差异,即使它们是同一用户和shell(whoami
,echo $SHELL
(,也许是指同一设置文件(/.bashrc
等(?
conda activate
应该在新的bash.exe中完成。我应该检查什么?谢谢。
相同的问题。首先,您必须从Bash Shell中运行:
conda init bash
它会将一些命令添加到~.bash_profile
,但看起来像从VSCODE启动终端不运行.bash_profile
只需将下面的命令从~.bash_profile
移动到~.bashrc
,一切正常
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
eval "$('/c/Miniconda3/Scripts/conda.exe' 'shell.bash' 'hook')"
# <<< conda initialize <<<