Ctrl + Alt + n opens code runner terminal but shows errors

Hello friends, i am learning Python; got a doubt in lesson 9 - Running Python Code; would appreciate if anyone can clarify it. Thanks.
[Python 3.10.6 in windows 10]
Ctrl + Alt + n opens the code runner terminal, but shows error. I am unable to understand why.
When the same code is run via (Ctrl + ~ ) it shows the correct result.
PFA the screenshot

It looks like Python does not support that particular emoji character when printing. If you remove the emoji, save the file and run again it works right?

Hi, jmrunkle, thanks a lot for your timely response. Yes, the emoji is not recognised while using the short cut key - (Ctrl + Alt +n).
But when the same code is run via (Ctrl + ~ ) it shows the correct result. This is what i don’t understand.
PFA the screenshot

It looks like the first version is passing the -u flag to the Python binary whereas the working version does not. If you enter the following manually into the terminal what is the output:

python -u revise2.py

Maybe check code runner settings in the extensions menu

Hi jmrunkle,
Thanks for your response. It worked fine when i manually entered it into the terminal. PFA the screenshot

Hi D0II4R,
Thanks for your response. I just started learning Python; it would be very helpful if you could be a little more specific on the steps to be followed & what exactly i should be looking for in the code runner settings.
I tried to navigate to code runner settings - is this the right screen? PFA the screenshot.

In that case, there must be some encoding specific to the code runner that it does rather than simply running it in the terminal.

Found this issue for basically the same problem on GitHub:

I think that workaround would work here, open up your settings.json file (probably under File > Preference > Settings) and add:

    "code-runner.runInTerminal": true

Bingo ! it worked after applying your mentioned change. PFA the screenshot.
Thanks a lot, jmrunkle !

1 Like

The correct image is attached here.

Thanks jmrunkle for helping him, by the way if you don’t want the text when you run through code runner like: finished (0.15s)

So you should change the code runner settings and yes you were on the correct page in the code runner settings, hope it helps, I don’t remember the exact setting but you can just search it yourself, hope this helps!

One of the settings which should be turned on is: Clear previous Output

Thanks D0II4R, followed your settings and it worked. Thank you.

1 Like

no problem at all! glad it helped you :slight_smile: