在 Visual Studio Code 中使用 Anaconda [英] Working with Anaconda in Visual Studio Code
问题描述
我在这里有点困惑,在撰写本文时,最新的 Anaconda Distribution 2018.12 带有安装 Microsoft Visual Studio Code 的选项,这很棒.
在启动 VSC 和 Python: Select Interpreter
和全新安装的 Anaconda 之后,我可以看到 ~Anaconda3python.exe
我认为它是 Anaconda Python环境,但是,当我尝试运行一些命令时,我得到:
PS ~DocumentsPython Scriptsvs>~/Anaconda3/Scripts/activatePS ~DocumentsPython Scriptsvs>康达激活基地
<块引用>
conda :术语conda"不被识别为 cmdlet 的名称,函数、脚本文件或可运行的程序.检查拼写名称,或者如果包含路径,请验证路径是否正确并且再试一次.在行:1 字符:1
现在我知道它可能与环境变量有关,但我发现它很奇怪,因为在 Anaconda 安装期间,有特别提到不需要将 Anaconda 路径添加到环境变量中.然而,在错误发生后,集成终端设法启动 Python,我能够运行代码.
接下来是在运行一个简单的脚本后我无法在调试器中查看任何变量,如教程中所示 这里:
msg = "Hello World"打印(味精)
我确实希望看到链接中显示的类似结果,例如 dunder 变量,我还按照以下步骤使用 stopOnEntry = True
更新了我的 launch.json
.
我想知道是否可以将 Visual Studio Code 与 Anaconda 一起用作解释器,而无需注册原始发行版中的变量,以及我是否遗漏了所需的任何内容.
我希望体验更直接,但我也可能遗漏了一些东西,我在 Windows 10 上运行.
激活 conda 环境不会将 conda
置于您的 PATH
中.如果您没有检查,您需要从开始"菜单启动 Anaconda Prompt
应用程序,以在 PATH
上获得带有 conda
的命令行在安装过程中包含 conda
的框.
另请注意,conda
自 2019 年 1 月发布的 conda
4.6 起仅支持 PowerShell.
VS Code 的 Python 扩展与 conda
一起工作得很好.创建一个 conda
环境,扩展程序将允许您选择它作为您的环境/解释器.
I am getting a bit confused here, the latest Anaconda Distribution, 2018.12 at time of writing comes with an option to install Microsoft Visual Studio Code, which is great.
When launching VSC and after Python: Select Interpreter
and with a fresh install of Anaconda, I can see ~Anaconda3python.exe
which I assume is the Anaconda Python Environment, however, when I try to run some commands, I am getting:
PS ~DocumentsPython Scriptsvs> ~/Anaconda3/Scripts/activate
PS ~DocumentsPython Scriptsvs> conda activate base
conda : The term 'conda' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1
Now I know that it might be related to the environment variables but I find it highly odd as during the Anaconda installation, there are specific mentions that it is not required to add the Anaconda path to the environment variables. However after the error, the integrated terminal manages to launch Python and I am able to run code.
Next in line is that I am unable to view any variables in the debugger after running a simple script, as shown in the tutorial here:
msg = "Hello World"
print(msg)
I do expect to see similar results as shown in the link such as the dunder variables, I have also updated my launch.json
with stopOnEntry = True
following the steps.
I would like to know if it is possible to use Visual Studio Code with Anaconda as a interpreter without registering variables from the original distribution and if I am missing out anything required.
I expected the experience to be more straight forward but also I might be missing something, I am running on Windows 10.
Activating a conda environment does not place conda
on your PATH
. You need to launch the Anaconda Prompt
app from your Start menu to get a command-line with conda
on your PATH
if you didn't check the box to include conda
during installation.
Also realize that conda
only supports PowerShell as of conda
4.6 which was released in January 2019.
And the Python extension for VS Code works with conda
fine. Create a conda
environment and the extension will allow you to select it as your environment/interpreter.
这篇关于在 Visual Studio Code 中使用 Anaconda的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!