Image.save producing 139?

448 views Asked by At

I am writing with the Anaconda distribution of Python2.7.7 and using the PyCharm editor.

I am trying to write a fairly simple program with a GUI that displays an image, has an editable text area, and has Enter and Cancel buttons. (It has to do more stuff of course, but I don't think it's relevant to this problem.)

I thought I had it working, but then it...stopped? I've edited it down to what I think is the minimum that, for me at least, still produces the error (okay, also the code to sorta center it).

For me what happens is this: when I run it now, it prints out "hi" and then "Process finished with exit code 139". But if I run it in Debug, it runs just fine, prints "hi" then "hi2" and displays the image (which is in the same folder as the code file).

I've tried looking up Image.save, but all I found was "If the save fails, for some reason, the method will raise an exception (usually an IOError exception).", which doesn't seem to be happening.

I've tried looking up exit code 139, but there isn't much to find it seems, except that it corresponds to SIGSEGV I think? But I don't know how to use that to help here.

Here's the code; any suggestions are appreciated!

import sys
from PyQt4.QtGui import *
import Image

class APP(QApplication):
    def __init__(self):
        QApplication.__init__(self, sys.argv)
        self.d = do_thing("image.jpg")
        self.d.show()

class do_thing(QWidget):
    def __init__(self, pm="image.jpg"):
        QWidget.__init__(self)
        self.layout = QVBoxLayout()
        self.lab = QLabel()
        im = Image.open(pm)
        print "hi"
        im.save("image.png")
        print "hi2"
        self.lab.setPixmap(QPixmap("image.png"))

        self.layout.addWidget(self.lab)
        self.setLayout(self.layout)
        fg = self.frameGeometry()
        center = QDesktopWidget().availableGeometry().center()
        fg.moveCenter(center)
        self.move(fg.topLeft())



if __name__ == "__main__":
    myapp = APP()
    sys.exit(myapp.exec_()

Update: I have tried printing the current directory; there is nothing unexpected there. It's right were it should be, in the same folder as the image. I have also tried passing save the full path, to no avail.

I know that an IOError and a segfault are very different. If it were an IOError I would at least have something to work from, but I'm lost with a 139. The weird thing is that it worked for a while, and I can't figure out why it stopped, or why it still works in debug, just not a regular run.

UPDATE: I tried the fix suggested here, but now, while it does print both hi statements, the window disappears as soon as it pops up, and I still get the exit code 139.

0

There are 0 answers