# Visual C++ Runtime error and Python/pythonw.exe crash

**URL:** <https://discourse.psychopy.org/t/visual-c-runtime-error-and-python-pythonw-exe-crash/9647>\
**Category:** Other\
**Created:** [October 30, 2019, 9:18am UTC](https://discourse.psychopy.org/t/visual-c-runtime-error-and-python-pythonw-exe-crash/9647 "2019-10-30T09:18:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mister36](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@Mister36](https://discourse.psychopy.org/u/Mister36)\
**Post date:** [October 30, 2019, 9:18am UTC](https://discourse.psychopy.org/t/visual-c-runtime-error-and-python-pythonw-exe-crash/9647/1 "2019-10-30T09:18:44Z")

</div>

Before yesterday, PsychoPy v3.1.5 was working and running experiments fine and as expected (on a Windows 10 PC), but since yesterday, when launching PsychoPy and going to the Builder or accessing Preferences, the attached error occurs. Nothing had been updated or installed between it last being known to work and this first occurring. However, it is a university IT-managed machine, so who knows?

![PsychoPy%20crash%20-%20Visual%20C%20%20%20Runtime%20Library%20issue](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/7/c/7c437b29b251937cf7c04fb1d44c1190c456ed20.png)

After OK is clicked, Python crashes:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/3/d/3d07244b0f1a617dcd6c2414a10e0d34f8ac70df.png)

We have tried updating PsychoPy to 3.2.4, both x86 and x64 versions, including uninstalling/rebooting in between, as well as manually updating the Visual C++ redistributable and Python (3.6.6 and 3.8).

If anyone has any ideas how to fix this, please let me know.

---

<div class="post-metadata">

**Author:** ![Mister36](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@Mister36](https://discourse.psychopy.org/u/Mister36)\
**Post date:** [November 5, 2019, 1:45pm UTC](https://discourse.psychopy.org/t/visual-c-runtime-error-and-python-pythonw-exe-crash/9647/2 "2019-11-05T13:45:32Z")

</div>

Running the [troubleshooting command](https://www.psychopy.org/troubleshooting.html) results in this:

```auto
C:\Windows\system32>"C:\Program Files\PsychoPy3\python.exe" -m psychopy.app.psychopyApp
A s s e r t i o n f a i l e d !

 P r o g r a m : C : \ P r o g r a m F i l e s \ P s y c h o P y 3 \ p y t h o n . e x e
 F i l e : s r c / h o s t a p i / w d m k s / p a _ w i n _ w d m k s . c , L i n e 1 0 6 1

 E x p r e s s i o n : F A L S E

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

```

Any ideas?

---

<div class="post-metadata">

**Author:** ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)\
**Post date:** [November 5, 2019, 4:19pm UTC](https://discourse.psychopy.org/t/visual-c-runtime-error-and-python-pythonw-exe-crash/9647/3 "2019-11-05T16:19:24Z")

</div>

a google search for the critical line:

> [@Mister36](#):
>
> s r c / h o s t a p i / w d m k s / p a \_ w i n \_ w d m k s . c , L i n e 1 0 6 1

reveals this:  
[expression: FALSE · Issue #2476 · psychopy/psychopy · GitHub](https://github.com/psychopy/psychopy/issues/2476)  
which suggests a problem with audio libraries (so my guess is that your IT people have done some sort of update to an audio lib that added an incompatible version).

Try changing the audio lib that PsychoPy is using by going to your userprefs file in `%appdata%\psychopy3` and set it to something like this

```auto
[hardware]
    audioLib = pyo, sounddevice, pygame

```

Or you could even put pygame first if you’re sure that sound timing doen’t matter to anyone using this machine!

---

<div class="post-metadata">

**Author:** ![Mister36](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@Mister36](https://discourse.psychopy.org/u/Mister36)\
**Post date:** [November 11, 2019, 3:54pm UTC](https://discourse.psychopy.org/t/visual-c-runtime-error-and-python-pythonw-exe-crash/9647/4 "2019-11-11T15:54:32Z")

</div>

Thank you so much for looking into this and providing this info, Jon. Much appreciated.

I had already taken the nuclear option and re-imaged the machine (as this is what IT did to solve the issue previously), but have noted this fix/workaround for if/when it happens again.

---

<div class="post-metadata">

**Author:** ![Mister36](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@Mister36](https://discourse.psychopy.org/u/Mister36)\
**Post date:** [November 15, 2019, 12:23pm UTC](https://discourse.psychopy.org/t/visual-c-runtime-error-and-python-pythonw-exe-crash/9647/5 "2019-11-15T12:23:26Z")

</div>

Sadly, the issue has returned (perhaps not surprisingly after a Windows update), but the suggested sound device userPrefs fix doesn’t work. ☹

However, this time it’s just Python that crashes and no mention of C++ runtime errors, so possibly a different issue? Deary me.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)\
**Post date:** [November 17, 2019, 11:18am UTC](https://discourse.psychopy.org/t/visual-c-runtime-error-and-python-pythonw-exe-crash/9647/6 "2019-11-17T11:18:45Z")

</div>

Sorry, could you clarify what’s happening now then? There are no error messages at all? And you’ve trying to run from the terminal but nothing happens? That’s very puzzling indeed.

---

<div class="post-metadata">

**Author:** ![Mister36](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@Mister36](https://discourse.psychopy.org/u/Mister36)\
**Post date:** [November 18, 2019, 9:18am UTC](https://discourse.psychopy.org/t/visual-c-runtime-error-and-python-pythonw-exe-crash/9647/7 "2019-11-18T09:18:53Z")

</div>

Apologies for not being clearer, Jon.

There’s no error other than the “Python has stopped working” dialog when opening via GUI.

When running the troubleshooting command line, I get the same as before (without the line starting "This application has requested…), but the userPrefs/audioLib workaround still doesn’t work here.

Please let me know if you have any other ideas and/or if there’s any other info I can provide to help.

---

<div class="post-metadata">

**Author:** ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)\
**Post date:** [November 19, 2019, 1:19am UTC](https://discourse.psychopy.org/t/visual-c-runtime-error-and-python-pythonw-exe-crash/9647/8 "2019-11-19T01:19:15Z")

</div>

I still feel like this is something to do with sound libs btu very hard to debug when I can’t go and start testing myself.

Let’s try and work out what parts of PsychoPy can/can’t load. Could you start up Python in the terminal:

```auto
C:\Program Files\PsychoPy3\python.exe

```

and then try importing psychopy as a second step (and possibly then parts of psychopy if the first one works):

```python
import psychopy
from psychopy import sound
from psychopy.app import psychopyApp

```

---

<div class="post-metadata">

**Author:** ![Mister36](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@Mister36](https://discourse.psychopy.org/u/Mister36)\
**Post date:** [November 19, 2019, 12:17pm UTC](https://discourse.psychopy.org/t/visual-c-runtime-error-and-python-pythonw-exe-crash/9647/9 "2019-11-19T12:17:32Z")

</div>

> [@jon](#):
>
> I still feel like this is something to do with sound libs btu very hard to debug when I can’t go and start testing myself.

I know, I’m sorry. But very grateful of your assistance.

> [@jon](#):
>
> and then try importing psychopy as a second step (and possibly then parts of psychopy if the first one works):
> 
> ```auto
> import psychopy
> from psychopy import sound
> from psychopy.app import psychopyApp
> 
> ```

Yep, you’re right. It crashes right after `from psychopy import sound`. And the hardware/userPrefs line for audio libs is **audioLib = pyo, sounddevice, pygame** and the crash occurs whether it’s that line or any one of those alone (which may or may not be expected).
