简体   繁体   中英

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).

My Settings 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:

    "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.

Try launching VS Code from your activated conda environment. Then from within VS Code select the environment you activated by running the Python: Select Interpreter command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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