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

**URL:** <https://discourse.psychopy.org/t/windows-error-pythonw-exe-has-stopped-working-please-help/1388>\
**Category:** Builder\
**Created:** [November 2, 2016, 12:28pm UTC](https://discourse.psychopy.org/t/windows-error-pythonw-exe-has-stopped-working-please-help/1388 "2016-11-02T12:28:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![raina](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@raina](https://discourse.psychopy.org/u/raina)\
**Post date:** [November 2, 2016, 12:28pm UTC](https://discourse.psychopy.org/t/windows-error-pythonw-exe-has-stopped-working-please-help/1388/1 "2016-11-02T12:28:43Z")

</div>

Hello,

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

I can run this experiment ([grmjudg.psyexp](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/1X/27002feed47105c78a13acf140efc95688f57d91.psyexp) (10.5 KB)) without a problem, but as soon as I introduce sounds(like [grmjudg2.psyexp](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/1X/9a72ccbcf43e321519802709ccfe1e96cbd8b027.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 [http://discourse.psychopy.org/t/randomly-python-exe-has-stopped-working-after-windows-update/1232/12](http://discourse.psychopy.org/t/randomly-python-exe-has-stopped-working-after-windows-update/1232/12))

Thank you!! Raina

---

<div class="post-metadata">

**Author:** ![daniel.riggs1](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/daniel.riggs1/32/8103_2.png) [@daniel.riggs1](https://discourse.psychopy.org/u/daniel.riggs1)\
**Post date:** [November 3, 2016, 7:16pm UTC](https://discourse.psychopy.org/t/windows-error-pythonw-exe-has-stopped-working-please-help/1388/2 "2016-11-03T19:16:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![raina](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@raina](https://discourse.psychopy.org/u/raina)\
**Post date:** [November 4, 2016, 3:14pm UTC](https://discourse.psychopy.org/t/windows-error-pythonw-exe-has-stopped-working-please-help/1388/3 "2016-11-04T15:14:35Z")

</div>

Dear @daniel.riggs1,  
Thank you for your reply!  
This is the windows error message (in German) which says that python.exe has stopped working  
 ![](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/1X/0fe0ee54d73dcd8b6014f58a1810c4ba2409fb6d.PNG)

- 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:  
 ![](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/1X/6937f477d61e92998378c757303bedc13f786306.PNG)

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:

 ![](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/1X/5cb7a3a6d04f26d8b22567ad9742e94aa64c8ae0.PNG)

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

---

<div class="post-metadata">

**Author:** ![daniel.riggs1](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/daniel.riggs1/32/8103_2.png) [@daniel.riggs1](https://discourse.psychopy.org/u/daniel.riggs1)\
**Post date:** [November 4, 2016, 6:37pm UTC](https://discourse.psychopy.org/t/windows-error-pythonw-exe-has-stopped-working-please-help/1388/4 "2016-11-04T18:37:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![daniel.riggs1](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/daniel.riggs1/32/8103_2.png) [@daniel.riggs1](https://discourse.psychopy.org/u/daniel.riggs1)\
**Post date:** [November 4, 2016, 8:39pm UTC](https://discourse.psychopy.org/t/windows-error-pythonw-exe-has-stopped-working-please-help/1388/5 "2016-11-04T20:39:16Z")

</div>

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\[sound.py](http://sound.py)

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:

```python
        try:
            self.sndFile = sndfile.SoundFile(fileName)
            self.sndArr = self.sndFile.read()
            self.sndFile.close()

```

Change it to this:

```python
        try:
            self.sndFile = sendfile.SoundFile(fileName)
            sndArr = self.sndFile.read()
            self.sndFile.close()
            self._setSndFromArray(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.

---

<div class="post-metadata">

**Author:** ![daniel.riggs1](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/daniel.riggs1/32/8103_2.png) [@daniel.riggs1](https://discourse.psychopy.org/u/daniel.riggs1)\
**Post date:** [November 4, 2016, 9:21pm UTC](https://discourse.psychopy.org/t/windows-error-pythonw-exe-has-stopped-working-please-help/1388/6 "2016-11-04T21:21:01Z")

</div>

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 “[pysoundcard.py](http://pysoundcard.py)”, 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\pysoundcard.py

```

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

```auto
typedef enum PaHostApiTypeId
{
   paInDevelopment=0, /* use while developing support for a new host API */
   paDirectSound=1,
   paMME=2,
   paASIO=3,
   paSoundManager=4,
   paCoreAudio=5,
   paOSS=7,
   paALSA=8,
   paAL=9,
   paBeOS=10,
   paWDMKS=11,
   paJACK=12,
   paWASAPI=13,
   paAudioScienceHPI=14
} PaHostApiTypeId;

```

---

<div class="post-metadata">

**Author:** ![daniel.riggs1](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/daniel.riggs1/32/8103_2.png) [@daniel.riggs1](https://discourse.psychopy.org/u/daniel.riggs1)\
**Post date:** [November 4, 2016, 9:21pm UTC](https://discourse.psychopy.org/t/windows-error-pythonw-exe-has-stopped-working-please-help/1388/7 "2016-11-04T21:21:59Z")

</div>

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:

> <https://github.com/psychopy/psychopy/pull/1298>

> <https://github.com/psychopy/psychopy/issues/1300>
>
> There was a bug in Pysoundcard that was not allowing sound.py to correctly init (at least on Ubuntu 14.04, not sure...
