psychopy.org | Reference | Downloads | Github

Experiment won't run after updating PsychoPy

We updated PsychoPy to 1.84.1. Now, when we try to run our experiment, an error message pops up that reads TypeError: not enough arguments for format string. Does anyone know how to fix this? See entire message below:

Note: Dynamic code seems intended but updating is “constant”:
“corrAns”, in Routine trial2 (key_resp_10: Allowedkeys)
Traceback (most recent call last):
File “C:\Users\smoker\Desktop\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.
7.egg\psychopy\app\builder\builder.py”, line 1903, in runFile
script = self.generateScript(self.exp.expPath)
File “C:\Users\smoker\Desktop\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.
7.egg\psychopy\app\builder\builder.py”, line 2091, in generateScript
target=target)
File “C:\Users\smoker\Desktop\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.
7.egg\psychopy\app\builder\experiment.py”, line 206, in writeScript
self.flow.writeBody(script)
File “C:\Users\smoker\Desktop\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.
7.egg\psychopy\app\builder\experiment.py”, line 1472, in writeBody
entry.writeMainCode(script)
File “C:\Users\smoker\Desktop\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.
7.egg\psychopy\app\builder\experiment.py”, line 1662, in writeMainCode
event.writeFrameCode(buff)
File “C:\Users\smoker\Desktop\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.
7.egg\psychopy\app\builder\components\keyboard_init_.py”, line 167, in writeF
rameCode
allowedKeys)
TypeError: not enough arguments for format string

1 Like

Check the settings in your key_resp_10 keyboard component, particularly the allowed keys field.

Now, when I go to open the experiment, it loads like it is going to open but then, Psychopy quickly closes and there is a new error screen. The only words I am able to read before it closes are “cannot support”.

My computer is Windows 7, could that be causing the problem?

It looks like the original error message is a bug we’ve introduced during recent refactoring. It only affects people specifying variables in the “allowed keys” entry, which I’m guessing you were?

Why it’s now not even loading I don’t know. I’ll upgrade you to Basic (from New) User so you can upload a copy of the experiment file for us to inspect and (hopefully fix)

thanks

2015-11-21 StroopTest-pilottest.psyexp (59.9 KB)

It appears that the path to the program was interrupted which we were able to correct. I think it may be the same issue for the “allowed keys”, for some reason the program can no longer locate the files that tell it what the correct answers are for the experiment.

I think I have it fixed but now when the participant gets to practice trial 2, it stops.

2015-11-21 StroopTest-pilottest_Trial2 Not Working.psyexp (60.3 KB)

Thank you for your help.

How would I go about entering variables into the “allowed keys” entry now after the recent refactoring?

The fixed file in PsychoPy is available here:
https://raw.githubusercontent.com/peircej/psychopy/7bb1e3967b4f8be08a33eb48f96af2328352df3b/psychopy/app/builder/components/keyboard/init.py

You’ll need to download that and replace the appropriate file in your installation. (psychopy/app/builder/components/keyboard/init.py)

Hi - rather than have separate topics, I thought I’d add to this one.

I’m on OSX El Capitan using PsychoPy 1.84.01 and an experiment I made in 1.83.04 is no longer working and is also providing a formatted string related error message:

Welcome to PsychoPy2!
v1.84.1
Traceback (most recent call last):
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/app/builder/builder.py”, line 1903, in runFile
script = self.generateScript(self.exp.expPath)
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/app/builder/builder.py”, line 2091, in generateScript
target=target)
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/app/builder/experiment.py”, line 206, in writeScript
self.flow.writeBody(script)
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/app/builder/experiment.py”, line 1472, in writeBody
entry.writeMainCode(script)
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/app/builder/experiment.py”, line 1224, in writeMainCode
self.loop.writeLoopStartCode(buff)
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/app/builder/experiment.py”, line 864, in writeLoopStartCode
buff.writeIndentedLines(code % inits)
TypeError: not enough arguments for format string

I’m using formatted strings to select image folders based on input from the dialogue box at runtime.

I have made the modification to the keyboard init.py file but it is not working - has anyone any clues?

I replaced my keyboard init.py file as well. Now, I no longer receive the error message but it still does not allow the participant to get past the part where I have the variable as the allowed keys.

Anyone have any experience or advice on this issue? Any help is greatly appreciated.

This is a fairly time sensitive issue for us- planned experiments are being delayed each day it is not fixed.

Thank you in advance.

Hi, can you not just downgrade until this issue is sorted out? :slight_smile:

I can’t replicate the problem. With the fixed keyboard/__init__.py file it seems to work for me. Could you either let me know what happens when you run the demo below or send a version that doesn’t work for me to test?

keyVary.psyexp (5.9 KB)

Oli I’ve just realised your issue was a different one that I haven’t addressed. Could you send a demo of that problem for me to study?

1 Like

Hi Jon,

This issue relates to using formatted strings within loops.

This worked in version 1.83.4 but not 1.84.

The attached example produces the error message but does nothing further.

BW

Oli

Example.psyexp (4.1 KB)

OK, Oli, your problem was different but that is fixed here:
https://github.com/psychopy/psychopy/pull/1253/commits/c903d5325bf66edf3e512dad7d85686543d60e0d

This one was caused by the PEP8 refactoring - making the lines pretty and short meant they didn’t wrok quite the same as before. :-/ That buglet is now fixed in repos

1 Like

We have reverted back to the previous version and it is running now. Thanks for your help!