These are my settings:
User Settings
{ "atomKeymap.promptV3Features": true, "editor.multiCursorModifier": "ctrlCmd", "editor.formatOnPaste": true, "python.pythonPath": "python3", "command": "python3", }
Workspace Settings
{ "python.pythonPath": "${workspaceFolder}/env/bin/python3.6", "git.ignoreLimitWarning": true }
tasks.json
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "0.1.0", "command": "python3", "isShellCommand": true, "args": ["${file}"], "showOutput": "always" }
If I use the debug console, the version and path is right:
But the output always defaults to "python2.7", no matter what I do.
How can I fix this?
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.
Working with Python in Visual Studio Code, using the Microsoft Python extension, is simple, fun, and productive. The extension makes VS Code an excellent Python editor, and works on any operating system with a variety of Python interpreters.
Under the view menu select 'show command pallet'. One of the commands you can then select from the command palette is 'Python: Select Interpreter'. Selecting this option will allow you to choose which version of python to use.
UPD. First, read the update #1 part in the bottom
(Try update#1 first) Looking at your screenshots I see you are using Code Runner extension. And I guess that is the way you are launching your programs. I don't know how it works internally, but adding this line into Code-Runner extension setting.json file fixed it:
"code-runner.executorMap.python": {... "python": "python3 -u", ...}
Found it in Code-Runner GitHub repository: https://github.com/formulahendry/vscode-code-runner/issues/366
If you type "python --help", you'll see "-u" flag stands for "unbuffered binary stdout and stderr..." - don't know why it matters here.
Update #1. This became not so convenient further - I started using python's virual environments and the solution above couldn't launch these environments, cause python3 (symlink) is always linking to the same python environment.
The solution here is to use Code-Runner's supported customized parameters, so you should change "python" line in it's settings.json to:
... "python": "$pythonPath $fullFileName", ...
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