GLException Error while running script in Coder

61 views Asked by At

EDIT: Here's a minimal reproducible example that should throw the same error. I have tried this on two different computers, and it throws the exact same error.

from psychopy import visual, core, event, data, gui
import pandas as pd

# Use a dialog box to get participant number
dlg = gui.Dlg(title="Participant Information")
dlg.addField("Participant Number:")
dlg.show()

if dlg.OK:
    participant_number = dlg.data[0]
else:
    print("User canceled, exiting...")
    core.quit()

# Load stimuli from stimuli.xlsx
stimuli_df = pd.read_excel("stimuli.xlsx")

# Define experiment phases and display durations
phases = [500, 750, 1000, 1250]

# Initialize PsychoPy window
win = visual.Window(size=(800, 600), fullscr=False, color="white")

# Initialize text stimulus
text_stim = visual.TextStim(win, text="", height=30)

# Initialize data storage
output_data = []

# Loop through each phase
for phase_num, duration in enumerate(phases, start=1):
    for word in stimuli_df["Word"]:
        # Display stimuli word
        text_stim.text = word
        text_stim.draw()
        win.flip()

        # Record onset time using core.Clock
        trial_clock = core.Clock()
        trial_clock.reset()

        core.wait(duration / 1000)  # Convert duration to seconds

        # Display prompt and collect participant response
        text_stim.text = "Please type the word you just saw. When you have finished, press ENTER."
        text_stim.draw()
        win.flip()

        # Record response time
        response_clock = core.Clock()
        response_clock.reset()

        response = event.getText()
        response_time = response_clock.getTime()

        # Append data to output
        output_data.append({"Phase": phase_num, "Word": word, "Response": response, "ResponseTime": response_time})

# Save data to output text file
output_df = pd.DataFrame(output_data)
output_df.to_csv(f"participant_{participant_number}_output.csv", index=False)

# Close PsychoPy window
win.close()

I am running into a GLException error while running a script in Psychopy. The script is intended to test the duration of exposure needed for participants to be able to successfully recall nonce words of various syllable-numbers. The error recurs in Windows 10 and 11. My system has enough memory, and all the fonts seems to be installed properly too…

pyglet.gl.lib.GLException: b'invalid value'
################ Experiment ended with exit code 1 [pid:18900] #################

Here’s the full output in case that helps. Any help is appreciated.

Traceback (most recent call last):
Hello from the pygame community. https://www.pygame.org/contribute.html
10.4986     WARNING     Monitor specification not found. Creating a temporary one...
  File "C:\Users\LENOVO\Desktop\EpochExp\responseEpoch_1.1_RT_GUI.py", line 45, in <module>
    text_stim.text = word
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\tools\attributetools.py", line 27, in __set__
    newValue = self.func(obj, value)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\text.py", line 381, in text
    self._setTextShaders(text)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\text.py", line 399, in _setTextShaders
    self._pygletTextObj = pyglet.text.Label(
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\text\__init__.py", line 456, in __init__
    self.document.set_style(0, len(self.document.text), {
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\text\document.py", line 603, in set_style
    return super(UnformattedDocument, self).set_style(
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\text\document.py", line 512, in set_style
    self.dispatch_event('on_style_text', start, end, attributes)
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\event.py", line 418, in dispatch_event
    if handler(*args):
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\text\layout.py", line 1073, in on_style_text
    self._init_document()
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\text\layout.py", line 1043, in _init_document
    self._update()
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\text\layout.py", line 966, in _update
    lines = self._get_lines()
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\text\layout.py", line 942, in _get_lines
    glyphs = self._get_glyphs()
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\text\layout.py", line 1085, in _get_glyphs
    glyphs.extend(font.get_glyphs(text[start:end]))
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\font\base.py", line 394, in get_glyphs
    self.glyphs[c] = glyph_renderer.render(c)
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\font\win32.py", line 471, in render
    glyph = self.font.create_glyph(image)
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\font\base.py", line 364, in create_glyph
    glyph = texture.fit(image)
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\font\base.py", line 254, in fit
    region.blit_into(image, 0, 0, 0)
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\image\__init__.py", line 1736, in blit_into
    self.owner.blit_into(source, x + self.x, y + self.y, z + self.z)
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\image\__init__.py", line 1629, in blit_into
    source.blit_to_texture(self.target, self.level, x, y, z)
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\image\__init__.py", line 1000, in blit_to_texture
    glTexSubImage2D(target, level,
  File "C:\Program Files\PsychoPy\lib\site-packages\pyglet\gl\lib.py", line 106, in errcheck
    raise GLException(msg)
pyglet.gl.lib.GLException: b'invalid value'
################ Experiment ended with exit code 1 [pid:18900] #################

Tried running the script in Coder (Standalone PsychoPy-2023.2.3, 64-bit), on Windows 11. Graphics driver is updated, and all fonts are installed.

0

There are 0 answers