Reputation: 51
I'm attempting to load images for sprites using the Python library pyglet. The original purpose was game-related, but I believe I have distilled the issue down to a single line of code. In the Python shell, I import pyglet, and then I run this line of code (or something equivalent):
pyglet.image.load("image.png")
Python quits, and the terminal outputs:
Segmentation fault (core dumped)
Sometimes it doesn't do this, though, and instead throws
Traceback (most recent call last):
File "/usr/lib/python3.4/site-packages/pyglet/__init__.py", line 351, in __getattr__
return getattr(self._module, name)
AttributeError: 'NoneType' object has no attribute 'load'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/site-packages/pyglet/__init__.py", line 357, in __getattr__
__import__(import_name)
File "/usr/lib/python3.4/site-packages/pyglet/image/__init__.py", line 145, in <module>
from pyglet.gl import *
File "/usr/lib/python3.4/site-packages/pyglet/gl/__init__.py", line 236, in <module>
import pyglet.window
File "/usr/lib/python3.4/site-packages/pyglet/window/__init__.py", line 1816, in <module>
gl._create_shadow_window()
File "/usr/lib/python3.4/site-packages/pyglet/gl/__init__.py", line 205, in _create_shadow_window
_shadow_window = Window(width=1, height=1, visible=False)
File "/usr/lib/python3.4/site-packages/pyglet/window/xlib/__init__.py", line 166, in __init__
super(XlibWindow, self).__init__(*args, **kwargs)
File "/usr/lib/python3.4/site-packages/pyglet/window/__init__.py", line 515, in __init__
context = config.create_context(gl.current_context)
File "/usr/lib/python3.4/site-packages/pyglet/gl/xlib.py", line 186, in create_context
return XlibContextARB(self, share)
File "/usr/lib/python3.4/site-packages/pyglet/gl/xlib.py", line 300, in __init__
super(XlibContext13, self).__init__(config, share)
File "/usr/lib/python3.4/site-packages/pyglet/gl/xlib.py", line 203, in __init__
raise gl.ContextException('Could not create GL context')
pyglet.gl.ContextException: Could not create GL context
or
Traceback (most recent call last):
File "/usr/lib/python3.4/site-packages/pyglet/__init__.py", line 351, in __getattr__
return getattr(self._module, name)
AttributeError: 'NoneType' object has no attribute 'load'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/site-packages/pyglet/__init__.py", line 357, in __getattr__
__import__(import_name)
File "/usr/lib/python3.4/site-packages/pyglet/image/__init__.py", line 145, in <module>
from pyglet.gl import *
File "/usr/lib/python3.4/site-packages/pyglet/gl/__init__.py", line 101, in <module>
from pyglet.gl import gl_info
ImportError: cannot import name 'gl_info'
(I'm not sure why it alternates between these two.)
In addition,
pyglet.window.Window()
also throws the exception
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/site-packages/pyglet/window/xlib/__init__.py", line 166, in __init__
super(XlibWindow, self).__init__(*args, **kwargs)
File "/usr/lib/python3.4/site-packages/pyglet/window/__init__.py", line 515, in __init__
context = config.create_context(gl.current_context)
File "/usr/lib/python3.4/site-packages/pyglet/gl/xlib.py", line 186, in create_context
return XlibContextARB(self, share)
File "/usr/lib/python3.4/site-packages/pyglet/gl/xlib.py", line 300, in __init__
super(XlibContext13, self).__init__(config, share)
File "/usr/lib/python3.4/site-packages/pyglet/gl/xlib.py", line 203, in __init__
raise gl.ContextException('Could not create GL context')
pyglet.gl.ContextException: Could not create GL context
when run from the shell. Sometimes it runs when run from a file (it'll run, fail on subsequent runs, and then eventually work for another run), and if I remember correctly it runs without issue from a Python program frozen with cx_Freeze.
I haven't managed to find anything newer than a couple years old on Google. I don't know much about OpenGL; at present I use pyglet because of how it simplifies building apps.
I'm running 64-bit Manjaro Linux with XFCE, an AMD CPU, and an AMD integrated graphics card (with the closed Catalyst drivers). I have Python 3.4.2 and pyglet 1.2.0.
Any ideas?
Upvotes: 3
Views: 1564
Reputation: 141
Now (2016.10.30) this issue is fixet. On the website development present report about it.
Pyglet website developers is an example of image loader: http://www.pyglet.org/doc/programming_guide/image_viewer.html.
In the my Archlinux system (Linux alw 3.19.1-1-ARCH #1 SMP PREEMPT Sat Mar 7 20:59:30 CET 2015 x86_64 GNU/Linux) this error persist - core dumped with the python-3, bat work fine with the python-2. I am used newest version of the pyglet - 1.2.2.
On MS-Win 8.1 this example works without any errors. I think the problem is in the wrong job this module.
I am reported about this bug on the development site https://bitbucket.org/pyglet/pyglet/issue/25/core-dumped-on-linux-64
Now you can use only PNG format:
...
from pyglet.image.codecs.png import PNGImageDecoder
fname = 'pennant.png'
img_pennant = pyglet.image.load(fname, decoder=PNGImageDecoder())
...
This code not core dumped.
Upvotes: 1