简体   繁体   English

VS Code中的Conda环境激活失败

[英]Conda environment activation fails in VS Code

When I launch a Python terminal or use Shift+Enter to run code from my Python Files through VS Code on Windows, I get a message: 当我启动Python终端或使用Shift + Enter在Windows上通过VS Code从我的Python文件运行代码时,我收到一条消息:

This Python interpreter is in a conda environment, but the environment has not been activated. 此Python解释器位于conda环境中,但环境尚未激活。 Libraries may fail to load. 库可能无法加载。 To activate this environment please see https://conda.io/activation . 要激活此环境,请参阅https://conda.io/activation

I get a Python prompt. 我得到一个Python提示符。 The code runs as expected. 代码按预期运行。 If I exit() that prompt and run "conda activate myenv", the environment activates and I can then run python using the desired environment. 如果我退出()该提示并运行“conda activate myenv”,环境将激活,然后我可以使用所需的环境运行python。 However, I can't seem to figure out why it's not activating by default. 但是,我似乎无法弄清楚为什么默认情况下它没有激活。

I have the MS Python module loaded. 我加载了MS Python模块。 Conda is up to date and in my system path. Conda是最新的,在我的系统路径中。 I've installed Conda into cmd and powershell. 我已经将Conda安装到cmd和powershell中。 And the expect "activate" command works if I quit python and type it in. Any ideas what I might be missing? 如果我退出python并输入它,期望“激活”命令有效。任何想法我可能会缺少什么?

Please check if you have this setting in your settings.json file, 请检查您的settings.json文件中是否有此设置,

"python.pythonPath": "<anacondapath>\\envs\\<yourenv>\\python.exe",

This should automatically load the conda environment for you. 这应该会自动加载conda环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM