2

I am using Python 3.7 and QGIS 3.4 to run a number of processes, and while I draft and debug my script I want to be able to occasionally stop, check if I want to continue, and then do so.

Usually, I would use input as so:

check = int(input("press 1 to continue"))
if check == 1:
     print("continuing")

This results in:

RuntimeError: input(): lost sys.stdin

However, this isn't working in the python console in QGIS. It seems like this might be a known bug in QGIS, but any answers I've found are pretty old and haven't worked, or are geared towards people creating plugins and actual UI.

I'm not looking for anything fancy - like I said, just using this for rough scripting and debugging on my own end.

0

Have you tried simply this?

    input("Press any key to continue...")

If the error in QGIS lies in using the input function, that won't help. However, if it's a problem with storing a variable, this bypasses it by simply pausing till you hit a key. Let me know if this doesn't work!

UPDATE Since that didn't work... this is ugly because it opens the cmd window, but provided you're using Windows it should work

    import os #At the beginning of your script
    os.system('pause') #in place of input()

It'll pop open the cmd window with "Press any key to continue..." displayed, and your code will proceed when you do. You can minimize the cmd window to inspect whatever you need to.

  • Ran and got the same: RuntimeError: input(): lost sys.stdin – jyingling Jan 28 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.