Python Forum

Full Version: Code Runner In VS-Code - Problem With User Input
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Any attempt to run python code involving user intervention like input() function fails with the message:

Quote:Cannot edit in read only editor

As a result, such files have to be run in the terminal.

However, the quality of presentation provided by Code Runner in Output pane of integrated terminal is found to be far superior.

It would be great if a solution could be found to run these files too in Code Runner output pane itself.
It's not a problem with taking user input. You did something to set your file/project as read only
Search setting code-runner.runInTerminal mark on.
In setting.json look like this.
"code-runner.runInTerminal": true,
(Sep-10-2019, 09:00 AM)buran Wrote: [ -> ]It's not a problem with taking user input. You did something to set your file/project as read only

There is no restriction on the file. Moreover, I am the sole user/owner/administrator on my Windows-10 computer.

Your conclusion would also imply that there should be a problem in executing the file in terminal as well, which is not the case. Moreover, any user interaction at run time, via input() etc is not meant to percolate to & try writing into the underlying code file itself.

Basically, the difference appears to lie in the fact that Output Pane of integrated terminal does not accept user interaction, while the terminal pane has no such constraint.
(Sep-10-2019, 04:10 PM)adt Wrote: [ -> ]Your conclusion would also imply that there should be a problem in executing the file in terminal as well, which is not the case. Moreover, any user interaction at run time, via input() etc is not meant to percolate to & try writing into the underlying code file itself.
It was you who claimed
(Sep-10-2019, 08:57 AM)adt Wrote: [ -> ]Any attempt to run python code involving user intervention like input() function fails with the message
And because that is not true in general case (I don't have such problem), the only plausible conclusion is you have made something to prevent running such files in integrated terminal
(Sep-10-2019, 01:03 PM)snippsat Wrote: [ -> ]Search setting code-runner.runInTerminal

Thanks for your kind observation. I had experimented with setting the runInTerminal property of code-runner to true,and there was no problem.

However, as explained in my post, I was trying to explore the feasibility of running user interaction code on output pane as its quality appears to be better than that on terminal pane.

On exploring the internet, there are quite a few postings raising this problem. the work-around suggested therein so far is the same as advised by you, i.e. running the code in terminal pane.

Perhaps the hitch might lie in the design of VS-Code itself, wherein the output pane has intentionally been kept immune from user interaction.

Results of some tests conducted at my end are placed below, for ready reference:

T-01:
Right Click > Run In Terminal:
Same results with Code Runner installed or Not.
Term Pane Name: Python , Output Pane: blank
Usual terminal clutter is present before commencement of output.

T-02:
Code Runner Installed and its runInTerminal property is set to true:
Press Ctrl+Alt+N for running the code:
Term Pane Name: Code , Output Pane: Blank
Usual terminal clutter is present before commencement of output.

T-03:
Code Runner Installed and its runInTerminal property is set to false:
Press Ctrl+Alt+N for running the code:
Output Pane Name: Code , Termial Pane: Cmd
Very neat output on the output pane.

T-04:
Default task named RunPython set via tasks.json
Same results whether Code Runner installed or Not
Press Ctrl+Shift+B for running the code.
Term Pane Name: Task-RunPython , Output Pane: Blank
In this case, the output of terminal pane is observed to be neatest as compared to other terminal based alternatives.

Conclusion:
If it is felt necessary to run code in terminal, doing so via a set task (Ref T-04 above), provides neatest output, almost matching output pane mode of Code Runner. This alternative works even if Code Runner is not installed.