I'm trying to run a python file in VSCode using python3.
I know I can fix by simply setting to run using integrated terminal like it says in the microsoft vscode tutorial on python. However, I would like the program to print in the output tab and not take up the terminal window.
The standard coder runner launch.json
looks like this;
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
I've tried to set my python path in VSCode in settings.json
...
"python.pythonPath": "python3",
"code-runner.executorMap": {
"python3": "/usr/bin/python3"
}
I've also set an alias for python -> python3 (as my ubuntu 20.04 doesn't come with python2 anymore)
alias python="python3"
However, I keep getting the above error. Any Ideas?
Configure VS Code for Python3 To get to that file, in vscode (mac) cmd+shift+P – type ' task ' – select ' configure task runner ', and edit the file to point the “ command ” at “ python3 ”, and the (command line) args to point at ${file} . Save, Debug/Run .. works! …
If this command does not return anything, it is likely that python is not installed (or undefined in the var env 'path') on your Mac. If you have a path to an interpreter, change the interpreter path used by vscode. Go to the settings and edit the field : "python : interpreter path" with the right one. Good day.
To do so, open the Command Palette (Ctrl+Shift+P) and enter Preferences: Open User Settings. Then set python.defaultInterpreterPath , which is in the Python extension section of User Settings, with the appropriate interpreter.
Nearly had it. This code
"python.pythonPath": "python3",
"code-runner.executorMap": {
"python3": "/usr/bin/python3"
}
should be
"python.pythonPath": "python3",
"code-runner.executorMap": {
"python": "/usr/bin/python3"
}
(The difference is at the beginning of line 3)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With