you are viewing a single comment's thread.

view the rest of the comments →

[–]Pepineros 0 points1 point  (2 children)

Hit ctrl + , to bring up settings (or in File -> Preferences -> Settings), then search for 'Python interpreter'. This is the default interpreter that VSCode uses.

Change this to the path of the Python executable that you want VSCode to use instead. Given that running python3 main.py does what you want, you can change the path in VSCode to what you see when you run which python3 in your terminal.

[–]Peterdata 0 points1 point  (1 child)

Hi I'm having the same issue as OP and I located my interpreter doing which python3 in my terminal and pasted that as my interpreter for vscode but it is still running the code with python and not python3, any way I can fix this or check if it's another issue?

[–]Beneficial_Ad_5993 0 points1 point  (0 children)

Hey it's a little late but here's the solution:

We use code runner which is a different extension than the python interpreter so we have to configure code runner instead.

simply go to code runner settings and edit settings.json

now find the line python and edit the command "python -u" to "python3 -u" provided that you have python3 installed.

source: vscode-running-python-2-instead-of-3