Python Forum
Code Runner In VS-Code - Problem With User Input
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code Runner In VS-Code - Problem With User Input
#1
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.
A.D.Tejpal
Reply
#2
It's not a problem with taking user input. You did something to set your file/project as read only
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Search setting code-runner.runInTerminal mark on.
In setting.json look like this.
"code-runner.runInTerminal": true,
Reply
#4
(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.
A.D.Tejpal
Reply
#5
(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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
(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.
A.D.Tejpal
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Convert Python code to MATLAB code bitoded 4 4,823 Dec-30-2022, 02:06 AM
Last Post: Larz60+
  looking for code that substitues parts of python code Skaperen 0 1,181 Jul-07-2022, 11:34 PM
Last Post: Skaperen
  Problem with VS code and Anaconda angelica 2 2,601 Feb-15-2021, 06:57 PM
Last Post: bishwasbh
  visual studio code python how to get source code of import module definitian umen 2 3,865 Jun-13-2020, 06:20 PM
Last Post: umen
  How to Rewrite MATLAB code to Python code Roc_Wizard 1 2,743 Jul-21-2018, 05:32 PM
Last Post: Larz60+
  Recovering lost source code when the code is running in memory micseydel 13 9,526 Apr-14-2017, 02:35 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020