| Reference | Downloads | Github

Error with demo code moviestim2 on psychopy 1.90.3 (on windows OS)



StandalonePsychoPy2-1.90.3-win32 installed on 64bit window 10

cv2 and vlc installed

moviestim2 can run, but the error occured when press stop or pause.

moviestim2 is needed for my experiment because moviestim3 response slowly when playing movie forward or backward.

Does anyone have any ideas on this? really appreciate it.

Traceback (most recent call last):
  File "D:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\demos\coder\stimuli\", line 72, in <module>
    if mov.status in [visual.PLAYING, visual.PAUSED]:
AttributeError: 'module' object has no attribute 'PAUSED'
Exception WindowsError: 'exception: access violation reading 0x00000028' in <bound method MovieStim2.__del__ of <psychopy.visual.movie2.MovieStim2 object at 0x201524B0>> ignored



Can you try using MovieStim3? It’s newer and may be less problematic.
My experiments used MovieStim3 to play videos and it worked without problems with sounddevice as the sound backend.



Hi Yuhan,

thank you for your reply.

however, with MovieStim3, I got this below error when moviestim run several trials

Traceback (most recent call last):
  File "D:\Research\PsychoPy2实验\", line 634, in <module>
  File "D:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\visual\", line 134, in __init__
  File "D:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\visual\", line 194, in loadMovie,
  File "<decorator-gen-72>", line 2, in to_soundarray
  File "D:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy\", line 54, in requires_duration
    return f(clip, *a, **k)
  File "D:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy\audio\", line 114, in to_soundarray
  File "D:\Program Files (x86)\PsychoPy2\lib\site-packages\numpy\core\", line 237, in vstack
    return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)


The error message indicated that the program is running out of memory.
It may relate to the size of videos, because videos require much larger memory than images.
Here’s some possible solutions:

  • Close other applications when running the experiment to decrease the memory usage.
  • Use “smaller” videos. If the original videos are 1280x1024 or something like that, transform them to lower resolution, like 640x480, may help.
  • Delete the used MovieStim3 objects. If the videos will not be used again. Try to delete them after playing to release memory. e.g.,
    timer = core.Clock()
    vid1 = visual.MovieStim3(win, "video1.mp4")
    dur = vid1.duration
    # play the video
    while timer.getTime() <= dur:
    # remove the video to release memory
    del vid1
  • Increase the RAM of your computer (My computer has 16GB of RAM)

Hope that helps!


Hi Yuhan
my pc also has 16GB RAM and the size of all my videos adds up to about 256M,


The memory usage is not the sum of the video size. It’s the resolution that matters.

If you don’t find a way to release the memory occupied by the MovieStim objects (or add more memory), Python will crash.