How to change code runner on vs code from python u to python 3

Hello, I am starting the python course and I am on a Mac so I need to change the default python code runner from python u to python 3. the tutorial cant be used on the current vscode version. please does anyone know how to change this

I’m also experiencing the same problem on Mac, anyone with any useful information please

Hey Mattie. By any chance did you figure this out

Having the same problem on mac. Sublime text uses python3 but cannot get VS Code to recognize it. Homebrew shows Python 3.9.

In vs code press shift + command + p.
Search for python interpreter and click on “Python: select interpreter”
On the top it has an option “Enter interpreter path”. Select that and enter the path to the python version you downloaded and installed on your machine.
Hope this helps you friends.

If you still haven’t firgured this out.
I hope this helps you.

I followed the steps but it’s still showing python -u :frowning:

Make sure you are entering the correct path to your interpreter .
In your terminal run “where python3.10” or whichever version you wanna use and copy the path it gives you and paste it in VsCode. When you selected the path restart VsCode.

Thank you for your help but I can’t get the path at terminal. It said invalid syntax :frowning:

You’re probably running the “where python3” command in the VsCode terminal.
Your VsCode terminal is probably running python so when you enter the command it tries to run the command as a python code. That’s why it’s saying invalid syntax.
Make sure it’s not running python or use the your computer’s terminal instead of your project’s terminal to get the path to your interpreter.

I got it. Thank you!

1 Like

Did you successfully change your python to python3 ?

When I was clicking on the triangle (run code) it told me: python -u bla bla error
Then I clicked on the arrow pointing down near this triangle and selected: run python file and this is working with my selected interpreter.
Run code (triangle) is still running with python -u and not working for some python files

update:
I downloaded python package from the official site and now everything seems to work

I got the same issue. After digging in the introduction of Code Runner, I found out the the default command for running python is “python -u”.
Simply go to the settings>Extensions>Run Code Configuration then find executorMap, and click the “Edit in setting.json” button.

You’ll see something like this screenshot. Edit the “python” line, make sure it’s "python": "python3 -u"
image

1 Like

Hello everyone, I can share what that worked for me. Hope it’s helpful to you too. It’s a temporary solution, helpful if you are working with a specific language

Step 1: Go to your Mac’s terminal and type: python3 – version
You will see something like this: Python 3.11.2
copy the whole version name

Step 2: Go to VS->Extensions → Code runner
Click on the gear to the right of the to Uninstall button → Extension settings
Scroll down to the 4th option: Code-runner: Default Language
Paste the Python version you copied in Step1
This should work :crossed_fingers:

PS. If you scroll further down to the 6th setting you will find the executor map settings mentioned in the video. Then chose edit settings.json. I followed the video instructions by changing python -u to python3 (since you are directly in user settings) but it didn’t work for me. You can try that too maybe it works

2 Likes

Thank you!!! This worked for me.

how did you edit the setting.json file? it is into read only mode for me