Search code examples
python-2.7pygletraspberry-pi4

Pyglet - TypeError: expected string or buffer


I'm trying to use pyglet instead of pygame, 'cause it supports several screens. this is a sample code that I run:

import pyglet

display = pyglet.canvas.get_display()
screens = display.get_screens()
window = pyglet.window.Window(fullscreen=True, screen=screens[1])

pyglet.app.run()

and I get this error:

Traceback (most recent call last): File "/home/pi/netcomShopTV/idk.py", line 5, in window = pyglet.window.Window() File "/usr/local/lib/python2.7/dist-packages/pyglet/init.py", line 359, in getattr import(import_name) File "/usr/local/lib/python2.7/dist-packages/pyglet/window/init.py", line 1890, in gl._create_shadow_window() File "/usr/local/lib/python2.7/dist-packages/pyglet/gl/init.py", line 209, in _create_shadow_window _shadow_window = Window(width=1, height=1, visible=False) File "/usr/local/lib/python2.7/dist-packages/pyglet/window/xlib/init.py", line 171, in init super(XlibWindow, self).init(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/pyglet/window/init.py", line 642, in init self._create() File "/usr/local/lib/python2.7/dist-packages/pyglet/window/xlib/init.py", line 265, in _create self.context.set_vsync(self._vsync) # XXX ? File "/usr/local/lib/python2.7/dist-packages/pyglet/gl/xlib.py", line 265, in set_vsync warnings.warn(e) TypeError: expected string or buffer

Pyglet Version: 1.4.8

I searched in internet, couldn't find anything to solve this problem.


Solution

  • It seems this bug was introduced with this recent change. You should definitely raise it on pyglet github issue tracker.

    Meanwhile, try installing the version prior to 1.4.8. (I though suspect this may just lead to crashing on failed sync as opposed to trying to warn you and then crashing :)).