VsCode Python "run code" vs "run Python File in Terminal"

Viewed 412

This is probably a quite common problem. I use conda on osx. I set my conda env on the bottom left corner and of course installed all my dependencies.

If I run a python file in the terminal, everything works fine. If I run it on the output console, I get errors. That's because the output console, somehow does not use the same environment like my terminal.

Output Code main.py:

import sys
print(sys.executable)

===

Users/[myself]/anaconda3/bin/python

===

Terminal main.py:

import sys
print(sys.executable)

===

Users/[myself]/anaconda3/envs/myenv/bin/python

===

My user settings:

{
    "editor.minimap.enabled": false,
    "workbench.settings.editor": "json",
    "workbench.settings.openDefaultSettings": true,
    "workbench.settings.useSplitJSON": true,
    "python.formatting.provider": "yapf",
    "code-runner.clearPreviousOutput": true,
    "code-runner.showExecutionMessage": false,
    "terminal.integrated.inheritEnv": true,
    "terminal.integrated.shell.osx": "/bin/zsh",
    "editor.formatOnSave": false,
    "prettier.useTabs": true,
    "[javascript]": {
        "editor.defaultFormatter": "vscode.typescript-language-features"
    },
    "terminal.integrated.env.osx": {
        "PATH": ""
    },
    "[json]": {
        "editor.defaultFormatter": "vscode.json-language-features"
    },
    "[html]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "javascript.updateImportsOnFileMove.enabled": "always",
    "todo-tree.tree.showScanModeButton": false,
    "python.showStartPage": false,
    "[typescript]": {
        "editor.defaultFormatter": "vscode.typescript-language-features"
    },
    "latex-workshop.view.pdf.viewer": "external",
    "prettier.printWidth": 100,
    "[jsonc]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "workbench.sideBar.location": "left",
    "workbench.editorAssociations": [
        {
            "viewType": "jupyter.notebook.ipynb",
            "filenamePattern": "*.ipynb"
        }
    ],
    "jupyter.alwaysTrustNotebooks": true,
    "cSpell.language": "en,de",
}

I did not configure any workspace settings. Is there a setting that I have missed?

0 Answers
Related