Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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"
] }
like image 583
SeanJohn Avatar asked Jun 05 '17 04:06

SeanJohn


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

like image 69
kimbaudi Avatar answered Sep 21 '22 22:09

kimbaudi