psychopy.org | Reference | Downloads | Github

Randomly 'python.exe has stopped working' - After Windows update?

Wondering if anyone else has been having a similar issue.

One of my experiments was running fine on a Windows 10 pc, until about a week ago. I got the following error in PsychoPy:

Unexpected error loading library avbin
pyo version 0.6.6 (uses single precision)
10.3311 	ERROR 	avbin.dll failed to load.
                     Try importing psychopy.visual as the first library
                     (before anything that uses scipy)
                     and make sure that avbin is installed.

This was followed by a “pythonw.exe has stopped working” Windows error.

I changed my code so that psychopy.visual was imported first and checked that avbin was installed. I also played around with the version of avbin.dll in PsychoPy and in System32, based on some suggestions I found online. I no longer get an error in PsychoPy, but I still get the “pythonw.exe has stopped working” error.

I also tried running from the command line in case it was specifically pythonw.exe that was the problem, but then I just got “python.exe has stopped working.”

The only thing I can think of that changed from when this experiment worked to when it stopped working is that Windows installed updates. However, I’m running several other experiments, and this is the only one that crashes. A few other bits of info:

  • This experiment plays and records sound. I have other experiments that play sound, but this is the only one that records (and again, the only one that crashes).
  • I updated to 1.84.1, but that doesn’t seem to have made a difference
  • I tried running this on a Mac and it works. Haven’t been able to run on another PC yet.
  • The avbin file is avbin.dll in some places and avbin64.dll in others (this may be obvious to many of you…)

Has anyone else run into problems following the recent Windows update? Or any other ideas?

1 Like

Hi, the avbin message can, to my knowledge, be safely ignored as long as you don’t use certain movie stimuli.
PsychoPy 1.84.2 has just been released, could you try to update and see if the behavior persists? Are you using the standalone PsychoPy package? Can you try narrowing down which functions/which code specifically causes your experiment to crash?

I’d happily ignore it if the program would run. :slight_smile:

I’m trying the PsychoPy update - will report back. I’m having a really hard time narrowing down the problematic code because I’m not getting any errors from PsychoPy and it doesn’t always crash at the same point, but it does seem to mostly crash in the middle of playing the first audio file in a loop of trials that contain:

  1. Play audio file
  2. Record audio file
  3. Press key to go to the next file
    (If problem persists, I can send actual code.)

Just wanted to point out that this message is probably unrelated to the nasty behavior you’re observing :slight_smile:

You could possibly try to select a different audio backend. At least for playback, both PyGame and Pyo are supported. I don’t know about recording, though.

Quite possible, but it’s the only message I’m getting. :-/

Updating to 1.84.2 did not help.

In case it helps, I’m attaching the code for my practice trial, which plays an audio file (with text onscreen), records the participant’s spoken response, and ends when the participant presses “enter.” This seems to work fine.

I’m also attaching the code for my loop of experimental trials, which does the same thing, but also allows the participant to skip a sentence for later playback by pressing the space bar. The program is crashing at some point while the first audio file in this loop is playing, before it gets to the “record” screen.

Practice_Play&RecordAudio.py (6.5 KB)
TrialLoop_Play&RecordAudio.py (10.7 KB)

Hm there’s quite some stuff going on there, and way too much for me to really “understand” the code at a single glance. Even worse, I cannot run the code and step through it with a debugger, since it’s just snippets. Could you please try to provide some sort of minimal working example that would allow us to possibly reproduce your problem? Thanks!

I had a similar issue once I updated to 1.84 for experiments with audio which worked fine before. I reinstalled pyo and it’s fixed the problem as far as I can tell. Not sure why, but worth a try maybe?

1 Like

Heya, I’m experiencing similar problems. I’m on Win7 and recently updated to Psychopy 1.84.2 using the standalone version.
Not sure if it is related, but I can’t run my experiments anymore, since python crashes (no error message in Psychopy). I don’t think I’ve changed anything and there were no windows updates.
I have 3 experiment files, but they only differ by the stimuli used. The experiment using pictures works fine, but the 2 using videos don’t anymore. I’m using moviepy as backend (the others don’t work at all). Now, the weird part is that when I tell Psychopy not to use audio, then the experiments work. This is quite a problem, as the audio is very important for my experiments. Following the suggestion by markdatkinson64, I reinstalled pyo, but that didn’t change anything.
I probably should also mention that the crashing is not related to the complexity of the experiment or size of the stimuli. Even when I create a test-experiment with only the movie object and ITI, python crashes and even if I specify only 1 trial, it crashes. The crash always happens at the end of the video while the last frame is still visible. In the test-experiment showing only 1 video, I do get an error message in Psychopy: “File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\matplotlib\path.py”, line 496, in contains_point transform)
RuntimeError: Unknown exception in point_in_path” (This error does not show for my actual experiments).
I’d appreciate help on this issue and hope there is a solution. Thanks.

Running python (the “python.exe” file) in XP compatibility mode and giving it administrator rights (don’t know if that’s necessary…) seems to alleviate the problem for me for the time being. Since my task isn’t time critical, that’s OK for me, but I don’t know if this setting affects performance in more demanding taks?
/Thomas K.

Thanks, Thomas for this suggestion. I would have never thought of that.
I just tried it and the outcome is that one movie experiment runs through completely, but after completion I get an error saying: “portaudio error in Pa_AbortStream: Unanticipated host error”. This error wouldn’t bug me if I didn’t get the same error with the other movie experiment, which now aborts about half way through. It’s progress, but not quite there yet. Any ideas? Thanks again.

Update:
I found a solution: I suppose portaudio is related to pyo, so I changed the order in the Psychopy preferences to chose pygame over pyo. First, I received an error message saying there was no pygame module and indeed I couldn’t find pygame in my Psychopy folder. So I downloaded the respective pygame .whl and put it in the Psychopy Scripts folder. From there I installed it using the command window. Now all my video-based experiments are running smoothly to the end without any error messages. Phew!

1 Like

Dear @Tan!
I’m having a similar problem (see this other thread http://discourse.psychopy.org/t/windows-error-pythonw-exe-has-stopped-working-please-help/1388) and wanted to try out your suggestion with changing the order in the Psychopy preferences to chose pygame over pyo. Also in my case (PsychoPy version 1.84.2 Standalone on Win7) pygame is not yet installed, and I’m having trouble understanding how you installed that - to which Scripts folder (there are several…) did you copy the file? And how do you install something using the command window (where do I find the command window)? I’m sorry, I am not very experienced with all of this yet… I am using the builder view, and am inexperienced with coding!

Thank you!
Raina

@raina
Hm, I’ve only got 1 folder called ‘Scripts’, so I can’t help you there, I’m afraid.
To open the cmd window, you need to hold ‘shift’ and right click simultaneously, then click ‘open command window here’.
In the command window you type:
python -m pip install whateverthenameofthewhl.whl

On a different note, how long are the videos you’re using? My experience using pygame is that the psychopy experiment will abort due to memory skyrocketing when trying to load the audio of a video that is longer then 4.5min (‘memory error’). @jon, is this a bug and is there a way to fix this? The memory error occurs irrespective of the file size.

Best,
Tan

1 Like

Thank you Tan! I just encountered some issues related to pyo and python crashing when loading a sound. Thanks to your solution I was able to install pygame and adjust the settings in psychopy, now everything runs smoothly :slight_smile:

1 Like

@Tan I don’t know what the problem is. Yes, we’ve seen issues with pyo having memory leaks and maybe it’s caused by that. The latest version of PsychoPy on win32 will have pygame included (not on the mac version because pygame isn’t supporting 64bit python yet). I’ve also been adding a newer alternative to pyo called sounddevice that will hopefully fix some of the pyo memory issues (hopefully they aren’t related to portaudio per se because this does use portaudio as well). So fingers crossed that will help but I don’t have any clear answer for you I’m afraid.

1 Like

@jon Thanks for your response. I switched to pygame straight away, see here: Randomly ‘python.exe has stopped working’ - After Windows update?
Pygame sort of works for me, except for the issue with the length of the video. I just tried sounddevice and unfortunately, it doesn’t work for me. I think portaudio might be the issue indeed.
I want to say, I really like psychopy and prefer it to eprime. Since all my research is video-based, I hope there will be a solution eventually.

FYI The phrase “it doesn’t work” is almost never useful without an explanation of what went wrong. Was there an error message? What happened? There some of the possibilities (there are many more):

  • you tried to use sounddevice on a machine that didn’t have the necessary code (because I’m only just releasing it now as part of 1.85)
  • you did something wrong while trying to use it (set the preferences incorrectly)
  • you did everything correct and there is a genuine bug that I need to fix

The point is that I have no idea which of these is the case because you just said “it didn’t work” with no error message or description of what happened.

1 Like

@jon I thought it was implied that we’re talking about ‘memory error’, which is the current problem. My bad. I’m sorry, from your comment I could not derive that sounddevice is yet to come with an update. It sounded to me like it has been added and I just didn’t know about it. Regarding the preferences, I tried every possible combination - to my awareness. It’d be great if I did something wrong; should be an easy fix then. Previous problems were, when using pyo: “portaudio error in Pa_AbortStream: Unanticipated host error” (but experiment finished) and more importantly, as experiment aborted:

which is why I switched to pygame: Randomly 'python.exe has stopped working' - After Windows update? - #11 by Tan which is fine as long as my videos each are <4:30min. Everything longer than that will result in ‘memory error’ when loading the audio stream: I get this error message with every video longer than 4:30, regardless of file size or format. I get this error also on different machines. When I edit the videos to a shorter duration, it works (i.e. no memory error).

Following this discussion, I switched to pygame too (which solved the problems I had with presenting a movie), so thanks!
@Tan - I don’t know if this is relevant, but I also had a memory issue when using MovieStim3. However with MovieStim2 (combined with pygame), I can present movies that are 15 min long. If you’re using MovieStim3, it may be worthwhile trying MovieStim2