将vscode内置的终端改为bash终端
这里简述一下vscode中最新配置bash终端的方式,我看网上的方法配置的方式都是旧版的了,vscode已经提示不要再使用了。我们打开vscode的配置文件,
如今的配置方式应该是
"terminal.integrated.profiles.windows": { "bash": { //bash是自己取的别名 "path": "D:\\Git\\bin\\bash.exe", } }, "terminal.integrated.defaultProfile.windows": "bash" // 可以自定义默认终端
conda activate报错问题
由于conda activate命令会导致CommandNotFoundError
本质原因是在bash终端中只认source activate
命令。它不认识conda activate
,但它们的工作原理是一样的。
在将vscode内置的终端改为bash终端后,我出现了一下报错
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'.
解决办法
在用户目录下(即~目录)配置一个bash的配置文件.bashrc
echo "source activate" >> ~/.bashrc
这相当于bash启动时使用source activate
这个命令
它会使你每次打开bash都执行source activate
,这样就解决了报错问题
注意切换成base环境后头上会有个(base)
如果不想用base环境则使用命令conda deactivate
反激活环境
conda deactivate