| Reference | Downloads | Github

Windows Exception error when importing visual library


PsychoPy has recently stopped working here. There’s a Windows exception error when I try to import the visual library. I’ve pasted the traceback below. I’m running the coder on Windows 7, PsychoPy 1.85.6, and my graphics card is Intel HD Graphics 4600.

Searching online I found a suggestion to import pyglet at the start of the script and set pyglet.options[‘shadow_window’]=False. That caused the script to stop without a message; inserting debug messages revealed that the import visual call caused execution to return to the start of the script, which seems odd.

I’m not sure what’s changed at my end, but it might be relevant that I have another installation of Python, and I rwas experimenting with running a (non PsychoPy) Python script from within RStudio the day before I encountered this issue. When I run in my PsychoPy script I get .version_info(major=2, minor=7, micro=11, releaselevel=‘final’, serial=0)

Thanks for any assistance,

Traceback message:

Running: C:\Users\Google_Drive\My Experiments\Current\3yp\2017_2018\scripts\

Traceback (most recent call last):
File “C:\Users\Google_Drive\My Experiments\Current\3yp\2017_2018\scripts\”, line 6, in
from psychopy import visual
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\”, line 17, in
from .window import Window, getMsPerFrame, openWindows
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\visual\”, line 57, in
from psychopy import core, platform_specific, logging, prefs, monitors, event
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\”, line 44, in
from pyglet.window.mouse import LEFT, MIDDLE, RIGHT
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\pyglet\”, line 1876, in
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\pyglet\gl_init
.py", line 208, in create_shadow_window
shadow_window = Window(width=1, height=1, visible=False)
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\pyglet\window\win32_init
.py", line 133, in init
super(Win32Window, self).init(*args, **kwargs)
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\pyglet\window_init
.py", line 572, in init
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\pyglet\window\win32_init
.py", line 270, in create
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\pyglet\window\win32_init
.py", line 309, in switch_to
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\pyglet\gl\”, line 216, in set_current
wgl.wglMakeCurrent(self.canvas.hdc, self._context)
WindowsError: exception: access violation reading 0x00000018

I’m posting again, just in case anyone has any thoughts. The error in question prevents me from doing anything with PsychoPy – it’s not related to a particular script, e.g., I get the same error if I simply type:

from psychopy import visual

into the shell. It seems to be something to do with the pyglet library, but I don’t fancy trying to debug that …


Most likely this is a problem with graphics card drivers. Try and install graphics drivers from Intel rather than the ones that come from Microsoft. Microsoft has its own alternative to OpenGL (DirectX) and doesn’t exactly try hard to support OpenGL. If that isn’t possible you could try turning off the pyglet shadow window, as solution that’s come up in several posts but with a slightly different error message.

Hi Jon,

You were right – I had to try a lot of drivers (most of which turned out to be incompatible), but ultimately found an older one that seems to have done the trick.