Word learning task

Hi everyone

I’m new to coding so I’m sorry if it’s a dumb question :slight_smile:

I need to program a word learning task. Every trial consists of an image, accompanied by the correct word. I made an excel file in which I have 2 colums ‘words’ and ‘images’. For example: words: table, images: table.png.
My code looks like this (I know it’s not correct/complete, but I’m stuck…)

import pandas as pd
import time
from psychopy import visual

data = pd.read_excel(r’C:\Users\User\Documents\1ste master\Research Project Experimental Psychology\Stimuli RPEP\RPEP_conditions - kopie.xlsx’)
df = pd.DataFrame(data, columns=[‘words’, ‘images’])

#create window
win = visual.Window(fullscr = True)
duration = 0.25

#create word and image list
word_list = df[‘words’].tolist()
image_list = df[‘images’].tolist()

#create text and image stimuli
word_stim = visual.TextStim(win, text = “”)
image_stim = visual.ImageStim(win, image = “”)

#loop over every word
for i in (word_list):
word_stim.setText(i)
word_stim.draw()
time.sleep(duration)
win.flip()

#loop over every image
#for i in (image_list):
image_stim.setImage(i)
image_stim.draw()
time.sleep(duration)
win.flip()

win.close()

I get the following error:

OSError: Couldn’t find image ; check path? (tried: C:\Users\User\Documents\1ste master\Research Project Experimental Psychology\Stimuli RPEP)

The excel file, the psychopy file and all the images are in the same folder.

Why doesn’t it find my images? How do I make sure the correct image is displayed with the correct word?

Thank you very much for your help already!

Check what image it is looking for. This error might mean that it is failing to find an image with no filename. I think that the path in this error message normally includes the full file name.