1

So I have been looking online trying to find how can I compile my python program using python 3 on visual studio code. However, it seems that they are not much information out there regarding how to do it. Below is what my task.json file looks like. Is there something I am doing?

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "Python",
"isShellCommand": true,
"args": ["${file}"],
"showOutput": "always"
}

Any advise will be great thank you

3
  • Anybody to help in this topic please? Commented Dec 13, 2016 at 7:04
  • 1
    Have you tried installing any extensions? The top downloaded python extension works well enough for me. Commented Dec 13, 2016 at 7:15
  • Thank you for your answer. I just checked and I do have the extension Python for VS Code installed. But where in my file do I put this shebang instruction as they mentioned "To instruct on Python 2 or 3 the shebang must be present at the top of the python file !#/usr/bin/python2 or !#/usr/bin/python3"? Putting !#/usr/bin/python3 on top of my python file still does not run with python 3 Commented Dec 13, 2016 at 7:46

1 Answer 1

10

In VSCode, you need to specify the Workspace that you intend to use to run using particular Python version.

Press "Ctrl+Shift+P" and type "Interpreter" and select "Python: Select Workspace Interpreter" Selecting Python Interpreter

This will list the different versions installed on your machine. Select what you want.

Select the Python version

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you @PeeDi! I have been using pyCharm in the meantime as I could not find a way.
This sets "python.pythonPath": "/usr/bin/python3" in the user settings. Great, thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.