OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): v2020.2.10
What are you trying to achieve?:
I hope to randomly select some images from a folder to appear on the screen as stimulation, so I added the following codes with Code Component, hoping to achieve it, but it kept reporting errors. I don’t know what to do, and I hope to get help.Thanks
What did you try to make it work?:
import os
import random
filenames= os.listdir(’./pics/’)
random.shuffle(filenames)
list_for_centers=filenames[:10]
target=[]
for item in list_for_centers:
target_name=’./pics/’+item
target.append(target_name)
print(target)
What specifically went wrong when you tried that?:
14.3494 ERROR Couldn’t make sense of requested image.
Traceback (most recent call last):
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\visual\basevisual.py”, line 836, in _createTexture
im = tex.copy().transpose(Image.FLIP_TOP_BOTTOM)
AttributeError: ‘list’ object has no attribute ‘transpose’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “C:\Users\31279\pythonProject\exp2_test_lastrun.py”, line 353, in
image.setImage(target)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\visual\image.py”, line 305, in setImage
setAttribute(self, ‘image’, value, log)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\tools\attributetools.py”, line 141, in setAttribute
setattr(self, attrib, value)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\tools\attributetools.py”, line 32, in set
newValue = self.func(obj, value)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\visual\image.py”, line 292, in image
wrapping=False)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\visual\basevisual.py”, line 841, in _createTexture
raise AttributeError(msg)
AttributeError: Couldn’t make sense of requested image.
Exception ignored in: <bound method TextStim.del of <psychopy.visual.text.TextStim object at 0x0000022A168304E0>>
Traceback (most recent call last):
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\visual\text.py”, line 240, in del
File “C:\Program Files\PsychoPy3\lib\site-packages\pyglet\gl\lib.py”, line 97, in errcheck
ImportError: sys.meta_path is None, Python is likely shutting down
Experiment ended.
Include pasted full error message if possible. “That didn’t work” is not enough information.