Bugfixes for "Unable to share contexts" and "Portaudio not initialized"

I ran into this issue with PsychoPy 1.85.6 on some older Win XP laptops, so unfortunately those code changes, which are already included in 1.85.6 (via this commit), don’t seem to work.

It turns out, that even setting pyglet.options['shadow_window']=False at the very beginning of the try block does not prevent the “pyglet.gl.ContextException: Unable to share contexts” error. Furthermore, it even looks like that try block is never actually executed, because if you put logging.warning("Beginning of try block") at the very beginning of that try block, that message never makes it to the log.

Since I needed a quick solution, I have now put the pyglet.options['shadow_window']=False statement directly under import pyglet at the beginning of window.py (in C:\Programs\PsychoPy2\Lib\site-packages\psychopy\visual). That does fix the issue and makes PsychoPy usable again on those affected machines for our users.

In PsychoPy 1.9, window.py seems to have gotten rewritten substantially, so I am not sure how to apply this fix there. The error message is different there, too (“AttributeError: ‘PygletBackend’ object has no attribute ‘_isFullScr’”).

But if someone else needs to get PsychoPy 1.8x Builder experiments working on old PCs that produce "pyglet.gl.ContextException: Unable to share contexts // 'Window' object has no attribute 'useNativeGamma'" errors, you can patch your PsychoPy install the way I have described above to get it working again. I hope this helps others as much as this thread has helped me.

2 Likes