Using Python3 on Mac OS X With Visual Studio Code - not working

Viewed 9304

I cannot seem to get Python3 to work when debugging it continues to use Python2. I've tried a few things but still am unable to get it work. I verified Python3s path is /usr/local/bin/python3 Everytime I run a script to by

import sys
print(sys.version)

I still get 2.7.10 python 3 is installed and work correctly.

I have this in my launch.json and settings.json (type and request are both grayed out for some reason in the launch.json)

 {
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"program": "${file}",
"pythonPath": "/usr/local/bin/python3",
"debugOptions": [
    "WaitOnAbnormalExit",
    "WaitOnNormalExit",
    "RedirectOutput"
] }
4 Answers

To select a specific python interpreter, invoke the Python: Select Interpreter command from the Command Palette (⇧⌘P).

enter image description here

This will update your .vscode/settings.json file:

{
    "python.pythonPath": "/usr/local/bin/python3"
}

You should then be able to debug using python 3 interpreter or any other python interpreter is available on your machine.

if you use "code runner",you can try to open user settings with command palette.

{
    "code-runner.executorMap": {
        "python": "python3"
    }
}

it's work for me.

What worked for me is adding the following to User Settings:

{
    "python.pythonPath": "/usr/local/bin/python3"
}
Related