OsError Couldn't find image

OS Error:

What are you trying to achieve?: Need to be able to run experiment

What did you try to make it work?: Putting image files into folder

What specifically went wrong when you tried that?: Kept saying the same message

Running: C:\Users\Ibukun Dada\Downloads\Mini Projects B&B2 Experiment\flanker_experiment_lastrun.py_lastrun.py

pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)
Hello from the pygame community. Contribute - pygame wiki
3.5880 WARNING We strongly recommend you activate the PTB sound engine in PsychoPy prefs as the preferred audio engine. Its timing is vastly superior. Your prefs are currently set to use [‘sounddevice’, ‘PTB’, ‘pyo’, ‘pygame’] (in that order).
Traceback (most recent call last):
File “C:\Users\Ibukun Dada\Downloads\Mini Projects B&B2 Experiment\flanker_experiment_lastrun.py_lastrun.py”, line 342, in
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\image.py”, line 416, in setImage
setAttribute(self, ‘image’, value, log)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\tools\attributetools.py”, line 134, in setAttribute
setattr(self, attrib, value)
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\image.py”, line 382, in image
self.isLumImage = self._createTexture(
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\basevisual.py”, line 1022, in _createTexture
raise IOError(msg % (tex, os.path.abspath(tex)))
OSError: Couldn’t find image stimuli/nonfamous_flanker_3.jpg; check path? (tried: C:\Users\Ibukun Dada\Downloads\Mini Projects B&B2 Experiment\stimuli\nonfamous_flanker_3.jpg)
################ Experiment ended with exit code 1 [pid:20744] #################

Hopefully that image shows what the entire folder looks like. But the problem seems to be with my stimuli folder or my images? No matter how I reformat or try to change it it keeps saying that it cannot find the images in the folder even though the images are definitely in the folder. Any help would be really appreciated

Is your stimuli folder a shortcut rather than an actual folder?

The stimuli folder is a shortcut but I also tried it when it wasn’t a shortcut folder and that also didn’t work. It still said it couldn’t find the images

@jon @Becca might you guys potentially have any ideas for this at all? I would really appreciate it. Thank you!

could you please show us how you are referencing your image in your file? and show us how your images appear in your stimuli folder? have you tried to select the image directly from the image component in builder - is it the same as how you are referencing it in your spreadsheet?


Yes whenever I select a specific image from the stimuli folder into the image component that always runs and shows on the experiment, but when I try to refrence the conditions folder it always says the images cannot be found even though it finds the correct path each time (so it looks into the stimuli folder and even references the correct image but the OSError still says that image cannot be found). I’ve attatched a picture of how the images are referenced in the file and also a screenshot of how the images look in the stimuli folder. I’ve also got another experiment that is having the exact same problem in terms of the OSError and not finding images. I’d really appreciate any insight on this, thanks so much!

Have you tried using uppercase JPG rather than lowercase? in the file explorer they look to be uppercase (though in theory that shouldn’t matter)

Can you share an image of the way you reference the path?
Maybe you can include a simplistic version of the experiment so we can test it on our machine?


No I haven’t tried that but as you said I really don’t think that would change too much. In the other experiment I mentioned all the images are referenced as a lowercase jpg in both the conditions file and in the stimuli file too so that also shows how that might not make too much of a difference

In this experiment the path is referenced as stimuli/ then any of the images, the stimuli folder is in the exact same file as the Psychopy file. I can upload a compressed folder for the other experiment that I’ve been refrencing so you can test it on your machine. The compressed folder would just need to be decompressed, but it contains the condiitons file, stimuli folder and of course the PsychoPy file. Once again thank you so much for all of the help!

P&C2 Mini Project.zip (719.1 KB)

Did you notice the names of your images?
You accidentally typed the suffix in the name.

It’s better to always have the file extension on:

Just rename the images, and it should work :slight_smile:

1 Like

I changed the names and removed the extra .jpg on all of them. However this didn’t seem to change anything. I’ve uploaded a screenshot of the same OSError that it said. I’m beginning to think it could potentially be an issue with PsychoPy since the initial experiment I asked for help with didn’t even have the images tagged with an extra .jpg.

Any other ideas on what the issue could potentially be by any chance? Thanks so much for your help!

Even after adding in specific image files now it doesn’t seem to work at all, as opposed to when the file names had the extra .jpg and the experiment still ran with a specific image file name entered

I downloaded your zip, removed the extra file extension and got an error
AttributeError: 'str' object has no attribute 'setImage'
This is because you have two variables with the same name: One Variable in your conditions file is called “image” and then you named the image component on the “face” routine “image” as well. As the Variable image from your conditions file is created after the image component image the latter is overwritten and thus does not function as an image component any longer.

Solution: Just rename the image component on the face routine to something unique.

Thank you for pointing this out. However when I changed the image component to $image and even changed the name on the face routine to faces, I still got that same OSError. I’ve uploaded screenshots of all of this. It doesn’t seem to be able to find the stimuli folder anymore since the path doesn’t go towards the stimuli folder anymore. I’m still really unsure about this but I’m genuinely grateful for all of your contributions!

Did you change the stimuli folder/images so it’s not a shortcut anymore?
Because the experiment works fine on my machine.
Can you please share a screenshot of your experiment folder? The path of your experiment and the path of your stimuli folder seems to be different (from the images you have sent).


I don’t think the stimuli folder is a shortcut?? I didn’t change it into a shortcut file. I’ve uploaded a screenshot of the entire experiment folder. If the paths are different do you have any idea of how I might change it from my side so that the experiment works on my computer? Could it potentially be that Psychopy doesn’t work well with my computer then too potentially? Thank you kindly!

Or how might I un-shortcut the file if that happens to be the case? I’m just surprised it isn’t a shortcut file for you but it might be on my computer?

I am not sure why but some of your files are compressed; it sometimes causes strange behavior and might be the reason for the problem.

For each compressed file (2 arrows at the top right corner of the icon):

  • Right click → Properties
  • Click on Advanced
  • Untick Compress contents to save disk spaces

Let me know if it changes anything

Can you also take a picture of the images folder? from the inside?