psychopy.org | Reference | Downloads | Github

Module import order affects MovieStim3 function

Psychopy version: PsychoPy (1.85.3)
OS: OS X Yosemite (10.10.5)
Coder View

I was struggling to get MovieStim3 to work in my own script, even though it worked in the Demo (MovieStim.py). Here is the error I was getting:

Traceback (most recent call last):
File “/Users/vassiki/Desktop/CMID/presentation/video_pres.py”, line 228, in
clip_video.draw()
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/movie3.py”, line 417, in draw
GL.glPopAttrib()
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/pyglet/gl/lib.py”, line 104, in errcheck
raise GLException(msg)
pyglet.gl.lib.GLException: stack underflow

I was able to get my script to work by simply changing the order in which I imported modules from psychopy.

This was the original (non-functional) order:
from psychopy import locale_setup, core, event, gui, logging, visual, sound

And this was the one that worked:
from psychopy import visual, core, event, gui, logging, sound

The output from psychopy.prefs was the same in both cases (importantly, the window type used pyglet). Even though this issue is solved for me personally, I don’t fully understand why the order of loading modules mattered. It would be wonderful to have some clarification for the future.

Thanks!

I don’t know about the error, or why the import order matters, but I did notice that your second statement didn’t import locale_setup. Perhaps that was the problem?

Thanks for the suggestion, but I removed locale_setup simply because i’m not really using functions from that module. it’s presence or absence didn’t have any bearings on the error.

Have you managed to track down which specific imports, if they happen before visual, cause this issue?

My guess is that it has something to do with numpy or scipy, related to this error: ERROR avbin.dll failed to load