1

I'm testing the Script Runner plugin to run scripts in QGIS (I'm new with programming with Python in QGIS). For some reason I can't get a script with arguments to work. It throws this error with any script I execute (the sample ones too):

     Traceback (most recent call last):
       File "C:/Users/ag/.qgis2/python/plugins\scriptrunner\scriptrunner.py", line 548, in run_script
         print "----------%s----------" % datetime.datetime.now()
       File "C:/Users/ag/.qgis2/python/plugins\scriptrunner\stdout_textwidget.py", line 55, in write
         sys.__stdout__.flush()
     IOError: [Errno 9] Bad file descriptor

I've been checking both scriptrunner.py and stdout_textwidget.py, but I can't see what's the problem.

3
  • Hi - Did you ever get a resolution for this - does scriptrunner just not work in QGIS 2.18. The answer from S_Carter below is now helpful as it would require a full edit of the plugin which presumably should work.
    – LeasMaps
    Commented Oct 26, 2018 at 7:29
  • @LeasMaps I desisted. But haven't worked with Python and QGis in a long while so maybe it's resolved now.
    – DMS02
    Commented Oct 27, 2018 at 15:10
  • Thanks - I'm in the same boat as you so If I work it out I'll update the answer
    – LeasMaps
    Commented Oct 29, 2018 at 5:59

1 Answer 1

1

Possible duplicate of this question. Most likely the error stems from using the 'print' command. You should instead use:

QgsMessageLog.logMessage('-------%s-------' % datetime.datetime.now(), 'My Script')
2
  • That's not the source of the error. I've been doing some changes to scriptrunner.py and no matter what changes I do or what lines I delete, it will always report an error on line 548.
    – DMS02
    Commented Sep 16, 2016 at 9:06
  • This is not helpful - the question is about a commonly used plugin which doesn't seem to work - your answer involves editing the source for the plugin
    – LeasMaps
    Commented Oct 29, 2018 at 5:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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