Preloading stimuli during static period prevents 1.90.2 from successfully building the script to run the experiment

Hello everyone,

OS: Win10
PsychoPy version: 1.90.2
**Standard Standalone? Yes
**What are you trying to achieve?: I am trying to preload stimuli during a static component. I tried preloading images, then texts, then sounds (one at a time, and in different experiments), in a super simple experiment (1 routine: ISI (0.5s) followed by text or image or sound (stating at 0.5 and staying for 1.0). I tried to keep as simple as possible, exactly like the experiment from the first link, below. I also re-installed psychopy (py3) but nothing changed.

**What did you try to make it work?: I have tried the solutions from: Preloading text stimulus during static period prevents 1.84.1 from successfully building the script to run the experiment
and
Setting component during ISI results in TypeError
But it continues displaying the same error.

**What specifically went wrong when you tried that?:

Traceback (most recent call last):
File “C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\psychopy\app\builder\builder.py”, line 2039, in runFile
script = self.generateScript(self.exp.expPath)
File “C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\psychopy\app\builder\builder.py”, line 2247, in generateScript
target=target)
File “C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\psychopy\experiment_experiment.py”, line 140, in writeScript
self.flow.writeBody(script)
File “C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\psychopy\experiment\flow.py”, line 252, in writeBody
entry.writeMainCode(script)
File “C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\psychopy\experiment\routine.py”, line 168, in writeMainCode
event.writeFrameCode(buff)
File “C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\psychopy\experiment\components\static_init_.py”, line 101, in writeFrameCode
self.writeStopTestCode(buff)
File “C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\psychopy\experiment\components\static_init_.py”, line 131, in writeStopTestCode
self.writeParamUpdates(buff)
File “C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\psychopy\experiment\components\static_init_.py”, line 159, in writeParamUpdates
prms = self.exp.getComponentFromName(bytes(compName)).params
TypeError: cannot convert ‘Param’ object to bytes

Hi @rodrigo_dal_ben, this problem came up previously here. If you change line 159 in static_init_.py to the following, your experiment should run:

prms = self.exp.getComponentFromName(str(compName)).params

Hi @dvbridges,
I tried the proposed solution before posting and the error continued.
The traceback error message is the same, except for the last line that instead of saying “TypeError: cannot convert ‘Param’ object to bytes” says “TypeError: cannot convert ‘Param’ object to str”
Any other ideas?

For now, I am using the 1.90.2 py2 version and it is running fine.

Ok, the fix works in my recreation of the error. You could just remove the str call. Try that, and if it does not work please let me know.

Hi @dvbridges,
I replaced “bytes” for “str” in line 159, as you suggested, and the experiment worked on my other pc. Now I re-installed 1.90.2 py3 on my main pc, altered line 159 (again) and it worked perfectly! For some strange reason it had not worked before.
Thanks for all the attention and help!
best,

1 Like