VSCode conda激活基础,提供CommandNotFoundError [英] VSCode conda activate base giving CommandNotFoundError
问题描述
我的计算机上安装了Anaconda和Visual Studio Code.我的VS Code的默认终端是Git Bash.当我在VSCode中打开新终端时,它将立即运行以下命令:
I have Anaconda and Visual Studio Code installed on my computer. My default terminal for VS Code is Git Bash. When I open a new terminal in VSCode, it immediately runs the following commands:
C:/Users/ethan/AppData/Local/Continuum/anaconda3/Scripts/activate
conda activate base
这些命令中的第二个给出以下错误:
The second of these commands gives the following error:
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'.
我尝试在VSCode终端和Git Bash中运行 conda init bash
和 conda init --all
.它可以很好地处理该命令,但不能解决我的问题.我不知道错误的第二行是否适用于我,但即使适用,我也不知道如何更改被调用的命令,因为它是由VSCode自动完成的.每当我在VSCode中启动终端时(即使我的工作区中没有任何python文件),都会发生此错误,并且当我从Anaconda Navigator中的启动按钮启动VSCode以及自行启动VSCode时都会发生此错误.
I have tried running conda init bash
and conda init --all
both inside the VSCode terminal, and inside Git Bash. It handles that command fine, but it doesn't solve my problem. I don't know if the second line of the error applies to me, but even if it did, I don't know how to change the command being called because it is done automatically by VSCode. This error occurs every time I launch a terminal in VSCode (even if I don't have any python files present in my workspace), and it happens both when I launch VSCode from the launch button in Anaconda Navigator and when I launch VSCode by itself.
推荐答案
我遇到了同样的问题.对我来说,可以从conda窗口中启动VSC来轻松解决.
I had the same issue. For me, easily resolved by launching VSC from the conda window.
具体来说,打开您的cmd提示符(对我来说是Anaconda Prompt),然后使用"conda activate [envname]"激活环境.然后只需运行命令代码".这将启动带有已激活环境和关联变量的VS Code.从那里开始,调试按预期进行.
Specifically, open your cmd prompt (for me, Anaconda Prompt), activate the environment using 'conda activate [envname]'. Then just run the command 'code'. This will launch VS Code with the activated environment and associated variables. From there, the debug works as expected.
这篇关于VSCode conda激活基础,提供CommandNotFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!