Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python crashes when trying to write an output file #1711

Open
hroskes opened this issue Apr 8, 2024 · 2 comments · May be fixed by #1714
Open

Python crashes when trying to write an output file #1711

hroskes opened this issue Apr 8, 2024 · 2 comments · May be fixed by #1714

Comments

@hroskes
Copy link

hroskes commented Apr 8, 2024

I'm running the example code from the README:

import OpenEXR, Imath

width = 10
height = 10
size = width * height

h = OpenEXR.Header(width,height)
h['channels'] = {'R' : Imath.Channel(Imath.PixelType.FLOAT),
                 'G' : Imath.Channel(Imath.PixelType.FLOAT),
                 'B' : Imath.Channel(Imath.PixelType.FLOAT),
                 'A' : Imath.Channel(Imath.PixelType.FLOAT)} 
o = OpenEXR.OutputFile("hello.exr", h)
r = array('f', [n for n in range(size*0,size*1)]).tobytes()
g = array('f', [n for n in range(size*1,size*2)]).tobytes()
b = array('f', [n for n in range(size*2,size*3)]).tobytes()
a = array('f', [n for n in range(size*3,size*4)]).tobytes()
channels = {'R' : r, 'G' : g, 'B' : b, 'A' : a}
o.writePixels(channels)
o.close()

When I get to the OpenEXR.OutputFile, I get a "Python has stopped working" dialog box, or a Jupyter dialog box "The kernel has stopped unexpectedly."

I'm running on 64-bit Miniconda on Windows 11, in a clean environment where I just installed python and jupyter, then pip installed OpenEXR. I tried Python 3.12, then made a new environment with Python 3.7 (since that's the oldest version supported by the pyproject.toml). I also tried in conda environments on a different computer running Windows Server 2016. None of this works.

There's also a conda OpenEXR on conda-forge. I tried with and without that; I'm not sure what it is, but installing it is not sufficient to import OpenEXR without also pip installing OpenEXR.

Please let me know if there's any more info, or tests I can run, that would be useful in debugging.

@cary-ilm
Copy link
Member

cary-ilm commented Apr 9, 2024

Oops, sorry about that, that example code is wrong. I'll submit a fix momentarily, but the proper line should read Imath.Channel(Imath.PixelType(Imath.PixelType.FLOAT) ). And it's also missing a from array import array.

hroskes added a commit to hroskes/openexr that referenced this issue Apr 9, 2024
and raise error when running the buggy version
instead of python mysteriously crashing

fixes AcademySoftwareFoundation#1711
@hroskes hroskes linked a pull request Apr 9, 2024 that will close this issue
hroskes added a commit to hroskes/openexr that referenced this issue Apr 9, 2024
and raise error when running the buggy version
instead of python mysteriously crashing

fixes AcademySoftwareFoundation#1711

Signed-off-by: Heshy Roskes <[email protected]>
@hroskes
Copy link
Author

hroskes commented Apr 9, 2024

Thank you! That works for me.

I made a PR (#1714) and am trying to figure out who from my institution I should reach out to about the CLA. I'm hoping to get back to you about that later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants