I'm hoping to use raw_input() inside a loop to prompt the user when s/he wants to continue running the script. However, I'm getting an error:

Traceback (most recent call last):
   File "<input>", line 1, in <module>
EOFError: EOF when reading a line

Is this function supported in qgis' python console? If not, do you have any suggestion?

I don't need to read the user's input. I just need the loop to pause for a while to let the user do some other stuff, then when ready, to resume working again.

  • 1
    I'm not sure waiting for the user like this is a good idea. Why not make a UI for your script and turning it into a plugin. – Nathan W Mar 9 '13 at 12:38
  • You're probably right Nathan. It's supposed to be a quick and dirty script, and I haven't learned how to write a plugin yet. :) oh, btw, it needs to pause because the script is also doing some counting. – n1kn0k Mar 9 '13 at 13:32
  • 1
    The QGIS Plugin Builder plugin can give you a jump start with making your first plugin. – katahdin Mar 11 '13 at 2:26

It is a bug in PyQGIS. This is what i found http://mappinggis.com/2015/09/feed-back-como-introducir-valores-a-traves-de-pyqgis/

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • 4
    Please edit your answer to give a little more information - external links are notorious for going bad. – MaryBeth Sep 26 '16 at 16:04
  • Also, this is a link to a page in Spanish, FYI – Erich Purpur Nov 15 '18 at 15:22

This is a very old question but the problem seems to persist as of QGis v2.18.

I was able to work around this issue by installing the IPython QGIS Console plugin and running my script from there.


The alternative to raw_input is QInputDialog.getText as explained in Maximus' answer above. A quick and Dirty example would be:

##Import libraries
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
from qgis.gui import *
from qgis.utils import *

from PyQt4.QtGui import QInputDialog #this is for your dialogs

 tempTuple = QInputDialog.getText(None, "Your Name" ,"Enter your Full Name: ")
 userName = tempTuple[0]

see also: https://stackoverflow.com/questions/35707849/link-qinputdialog-text-to-a-variable

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.