Visual Studio Code无法在commandPrompt中自动激活虚拟环境,但可以与“基本conda环境”一起使用

时间:2019-07-24 14:17:34

标签: python visual-studio-code anaconda conda

检查此GIF。... The GIF I recorded with problem.

我使用了anaconda-navigator并创建了一个新的虚拟环境。 Visual Studio代码检测到此环境,我可以使用该环境进行调试。但是,它不会自动在内置命令提示符下激活该env。

The screen shot of what's happend

但是,如果我在VSCode中选择了'Anaconda3':conda,则Visual Studio确实会使用

int main(int argc, char **argv) 
{
    for (auto i = int{0}; i < argc; ++i) {
        // do something with argv[i];
    }
}

帮助我进入基本环境

The screen shot of successful activated with base env

我试图使用anaconda导航器创建一个新的env,但是它也不起作用。只能通过VSCode检测到它,但不会为我激活它。

这是怎么回事?

2 个答案:

答案 0 :(得分:0)

那是因为conda没有为powershell提供文件“ activate.ps1”,而为cmd提供了“ activate.bat”文件,因此您应将默认的shell(terminal)更改为cmd,然后conda env将被激活

答案 1 :(得分:0)

卸载并重新安装anaconda 3后,一切正常。这可能只是anaconda或VS的错误

相关问题