1

I have an iMac running High Sierra. I've been learning python and I use Atom or VScode.

One problem I've experienced in both of these is that if I run a python script with an input statement like: num = int(input("Enter a number: ")) it doesn't work.

It works fine running from a terminal, but not if I'm using Atom or VScode. There seems to be no way to input data into a python script while it is running unless you code it in.

Can anyone tell me how to interactively input data into my python script while it is running?

1 Answer 1

1

I figured out my answer for my question.

Atom Load the Hydrogen package for Atom. this will print output to bottom of editor window. From the Hydrogen package, ude the Run Cell or Run All options. A blank screen appears for your input.

VScode This problem only seems to appear when using the "Code Runner" extension. Running the code using other methods appears to work fine. If running the "Code Runner" extension using a method like num = int(input("Enter a number: ")) appears to work but when you try entering your input to get an error message popup that says "Cannot edit in read-only editor" It halts waiting for input which can't be entered. I have to kill the app to try another method. So best option is to avoid Code Runner for python scripts if input is required.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .