Image.save produces 139?

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

I'm trying to write a fairly simple GUI program that displays an image, has an editable text area, and has Enter and Cancel buttons. (More needs to be done, of course, but I don't think this applies to this problem.)

I thought it was working for me, but then ... it stopped? I edited it to what I think is the minimum, which, at least for me, still throws an error (okay, also the code for center sorting).

What happens to me is that when I run it now, it prints "hello" and then "Process ended with exit code 139". But if I run it in Debug, it works fine, prints "hi" then "hi2" and displays an image (which is in the same folder as the code file).

I tried looking for Image.save, but all I found was " If the failure fails, for some reason the method will throw an exception (usually an IOError exception). " Which doesn't seem to happen.

I've tried looking for exit code 139, but there isn't much to find, unless it matches SIGSEGV? But I don't know how to use this 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 tried to print the current directory; there is nothing unexpected. Correct, it should be in the same folder as the image. I have also tried traversal by keeping the full path, to no avail.

I know that IOError and segfault are very different. If it was an IOError I would have at least something to work with, but I got lost with 139. It's weird that it worked for a while and I can't figure out why it stopped or why it is still running in debug mode. and not in the usual way.

UPDATE: I tried to fix the suggested here , but now while it prints both hi statements, the window disappears as soon as it appears and I still get exit code 139.

+3


source to share





All Articles