| Reference | Downloads | Github

Windows error "pythonw.exe has stopped working" - please help!


I use: OS Windows 7 64-bit, and PsychoPy version 1.84.2 Standalone.

I can run this experiment (grmjudg.psyexp (10.5 KB)) without a problem, but as soon as I introduce sounds(like grmjudg2.psyexp (11.2 KB)), I get a windows error saying “pythonw.exe has stopped working” and the experiment crashes.

I have tried deactivating my firewall and antivirus-softwares, but that didn’t help.

Has anyone run into similar problems and found a solution? Since I definitely need audio in my experiments, this is a big problem for me. Would be great to get some suggestions!

(One suggestion I’m having trouble trying out is described in this other thread

Thank you!! Raina

Hello Raina, so is there any other error message? Could you post the full message if so?

If audio is to blame, there’s another additional backend instead of pyo and pygame called pysoundcard. Apparently it’s not quite as well tested and I personally haven’t tried it, but maybe it’s worth a shot. In your preferences, put ‘pysoundcard’ first in the list and try it out?

Dear @daniel.riggs1,
Thank you for your reply!
This is the windows error message (in German) which says that python.exe has stopped working

  • actually, this time I run the program it is python.exe, and sometimes it is pythonw.exe! Hm…
    Then psychopy does not give me an error message. Just this:

When I set pysoundcard in the general settings, then interestingly I dont get a windows error message, but the experiment can also not be run, giving me this error message:

WHat is the KeyError: ‘status’ ??
Thank you!

I took a good look at this, and it looks like this is a bug. Hopefully when I get a chance I’ll file an issue for this for the developers, but as @jon has mentioned elsewhere, pysoundcard is not well tested, but it was worth a shot.

So I’ve seen you post elsewhere on the forum about pygame not being included in the distribution of 1.84.2, and this being related to your issue here. Is that the case? In the future it might be good to include that information on this thread.

To see if pygame is installed, open the coder view, then toward the bottom click the “shell” tab. Enter “import pygame” (without the quotes) and hit enter. If nothing happens, then you do have it installed, otherwise it will give a not found error.

So if pygame isn’t installed, one thing to try would be installing it, but I’m not exactly sure how to do that for the standalone version on Windows (we can’t use pip). @jon , any help on this? Hopefully I’ve given sound advice on this.

Ok I actually got pysoundcard working on my machine for this.

If you want to try pysoundcard again, you would just have to edit a section of a file.

The file is:

C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.2-py2.7.egg\psychopy\

The same one in the error message you showed me. Make a copy of this file and name it something else to have a backup, in case something goes wrong.

All indentations are spaces (that’s very important! Either 8 or 12 spaces in this case).
At line 411, the file currently looks like this in 1.84.2:

            self.sndFile = sndfile.SoundFile(fileName)
            self.sndArr =

Change it to this:

            self.sndFile = sendfile.SoundFile(fileName)
            sndArr =

I think copy pasting from this posting should work.

Also, line 417 (now 418) says “Sound file %s could not be opened using pygame for sound”. Change pygame to pysoundcard.

But again, apparently this library isn’t super well tested. For me it’s now playing sound fine (though I had to fix another bug in a dependency, will post about this to github). It sounds like you have very simple requirements (just play a sound file). Hopefully this will be good enough for you.


I’m not sure if you’re going to get this error:

CDefError: 'enum PaHostApiTypeId' has no values explicitly defined: refusing to guess which integer type it is meant to be (unsigned/signed, int/long)

The file you need to modify is “”, and I think it’s here (sorry don’t use Windows much):

C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.2-py2.7egg\pysoundcard\

Again, make a backup of the file. Add these lines starting at line 112 (copy paste would probably be the best idea here):

typedef enum PaHostApiTypeId
   paInDevelopment=0, /* use while developing support for a new host API */
} PaHostApiTypeId;

Lastly (sorry for all the posts), here are the github issues opened, for those who may end up here in the next couple of days: