简体   繁体   English

带有 Anaconda 的 VSCode 在终端中的运行中找到模块,但在运行代码或调试器中找不到

[英]VSCode with Anaconda finds module in Run in Terminal but not in Run code or debugger

I have a really simple problem that I can't solve: when I run any python code in Integrated Terminal with vscode I can use my virtual environment created on Anaconda, but when I try to debug or use the button "run code" he clearly doesn't use my actual environment (and by that, don't finding my modules).我有一个我无法解决的非常简单的问题:当我使用 vscode 在集成终端中运行任何 python 代码时,我可以使用在 Anaconda 上创建的虚拟环境,但是当我尝试调试或使用“运行代码”按钮时,他清楚不使用我的实际环境(因此,找不到我的模块)。

My Settings Json:我的设置 Json:

{
"python.pythonPath": "C:\\Users\\Giovani\\anaconda3\\python.exe",
"python.autoComplete.addBrackets": true,
"python.jediEnabled": false,
"python.linting.enabled": true,
"python.formatting.provider": "black",
"editor.detectIndentation": false,
"python.terminal.executeInFileDir": true,
"editor.tabSize": 4 }

And Lauch.json:和Lauch.json:

    "version": "0.2.0",
"configurations": [

    {
        "name": "Python: Current File",
        "type": "python",
        "request": "launch",
        "program": "${file}",
        "console": "integratedTerminal"
    }
] }

Images showing the issue: Running without a problem in the integrated terminal: Running in terminal显示问题的图像:在集成终端中运行没有问题:在终端中运行

Running in "run code" or debugging: Run Code在“运行代码”中运行或调试:运行代码

Objective: Use the same virtual environment as in "python.pythonPath" on the debugger or the "run code" button.目标:使用与调试器上的“python.pythonPath”或“运行代码”按钮相同的虚拟环境。

Try launching VS Code from your activated conda environment.尝试从激活的 conda 环境中启动 VS Code。 Then from within VS Code select the environment you activated by running the Python: Select Interpreter command.然后从 VS Code select 中运行Python: Select Interpreter命令激活的环境。

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

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