Error message when trying to upload experiment to pavlova

URL of experiment:

Description of the problem:
Hello all,

I am trying to upload my experiment to Pavlovia. I did manage to upload a previous version of the experiment a couple of weeks ago. But currently when I try to upload my experiment I get an error message. I get (almost) the same error message when trying to view the javascript code of my experiment, so I expect something to go wrong when trying to convert the python code to javascript. However, I cannot quite seem to figure out where the problem exactly lies. The error message I get is as follows:

Traceback (most recent call last):
File „/Applications/“, line 1056, in findPathsInFile
File „“, line 1, in
NameError: name ‚condition‘ is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File „/Applications/“, line 1458, in onPavloviaRun
File „/Applications/“, line 1445, in onPavloviaSync
File „/Applications/“, line 846, in fileExport
File „/Applications/“, line 91, in generateScript
File „/Applications/“, line 229, in compileScript
File „/Applications/“, line 202, in _makeTarget
File „/Applications/“, line 356, in writeScript
File „/Applications/“, line 390, in writeFlowSchedulerJS
File „/Applications/“, line 1174, in getResourceFiles
File „/Applications/“, line 1070, in findPathsInFile
File „/Applications/“, line 1087, in findPathsInFile
File „/Applications/“, line 410, in importConditions
File „/Applications/“, line 304, in _assertValidVarNames
psychopy.exceptions.ConditionsImportError: Bad name: Before start
„Parameters (column headers) cannot contain punctuation or spaces“

I am not sure how to interpret this error message. I would be very grateful for any input.

Have you looked are your spreadsheets and checked the column titles for punctuation or spaces. A common error is a space after the title (so you can’t see it unless you check)

As far as I can see, there are no spaces and there is no punctuation in the column titles. I do use an underscore in a column title, but I understood that this is not a problem.

Do you have any additional columns? The easiest way to check is to save the spreadsheet in CSV format and open it in a text editor. If you still can’t find anything, please upload it here and I’ll check.

Also, check you haven’t used any of these reserved variable names: class, core, final, image, index, Length, list, Object, Number, round, sound, Symbol, t, thisTrial, trials, util, visual.

and you haven’t used a name that also appears as a component, routine or variable name in your experiment.

Thank you for your suggestions. I did have a column called list in my spreadsheet, so I took that out, because it was not crucial to the experiment. Additionally, I had a variable named condition. I have now changed that variable’s name. However, I still seem to be getting the same error, however now with ‘condition’ in the first part of the error changed to ‘randcond’ (the new name of that variable). I have uploaded my spreadsheets with this comment. I would be very grateful if you could take a look at them.
A.csv (785 Bytes)
B.csv (719 Bytes)

randcond isn’t in either of your spreadsheets. Please could you show where and how it is used?

In the beginning of the experiment, I have a code component that decides whether participants will see the items in the list A or list B.
The code here is:

Begin Experiment

import random
randcond = random.choice((‘A’,‘B’))

var randcond;

if ((Math.random() * 10) + 1 > 5) {
randcond = ‘A’;
} else {
randcond = ‘B’;

Then, in the trials loop, the conditions are set as such:

My understanding is that the use of var limits the scope of the variable to that code component.


randcond = 'B';
if ((Math.random() * 10) + 1 > 5) {
randcond = 'A';

Personally I would change the Python to

randcond = 'B'
if random() > .5:
     randcond = 'A'


conditions = ['A','B']
randcond = conditions[0]

I have changed the code in the code components to the code you suggested, but unfortunately, I still get the same error.

I have copied the first part of the error message again, since I now see that the formatting of the message lead to small parts being omitted here (I have now put the “<” and “>” in quotation marks so their contents have become visible):

Traceback (most recent call last):
File „/Applications/“, line 1056, in findPathsInFile
File „“<“string”>”“, line 1, in “<“module”>”
NameError: name ‚randcond‘ is not defined

Perhaps this changes something? But as I said, I am unfortunately still getting the same error message.

Does this error happen when you try to sync or are you testing locally?

Are you viewing the latest version of your code? Perhaps you could paste the link here if it crashes straight away.

When I test locally, there are no problems. However, when I try to Sync project/create project on Pavlovia, or when I try to open the javascript code, I get the error message. That’s why I believe it might have something to do with the translation from python to javascript.
Since I cannot sync the project, I cannot look at the latest version of my code on Pavlovia. Is that what you mean with viewing the latest version of my code?

What version of PsychoPy are you using?

I’m now wondering whether the issue is in the line of code before it gets to randcond. Do you have any Before Experiment code or Begin Experiment code before that line?

Is there anything unusual in your expInfo dialogue box?

I am using version 2023.2.3.

I don’t think I have any code before this coding element. At least I have not put in any code in with code components. I also don’t think there is anything unusual regarding my expInfo, but I am not very experienced with coding, so I am not sure how it is supposed to look. Would it perhaps help if I uploaded the code/this portion of the code here? Thank you anyways for all your help so far.

Please could you upload your psyexp file?

Of course. Here is the file: namingagreement_copy.psyexp (145.9 KB)

Your code component is set to Both. If I switch it to Auto

randcond = 'B';
if ((Math.random() * 10) + 1 > 5) {
randcond = 'A';

changes to

randcond = "B";
if ((Math.random() > 0.5)) {
    randcond = "A";

If you want to use your formula, which I think will give A 40% of the time then you could use > 0.6

However, the biggest difference I can see is single vs double quotes.

With this changed code, are you then able to produce a javascript code file? Because I changed the code, but am still unable to open the javascript code file or sync/create the project on Pavlovia.

I seem to have found the solution to my problem, so I thought I would post it. What worked for me in the end was, in the trials loop, instead of writing $“psychopy_list1/”+randcond+“.xlsx”, I wrote $“psychopy_list1/”+‘randcond’+“.xlsx”, so with randcond in quotation marks. This does make it so that the experiment no longer works locally, but psychopy now does manage to create the javascript code and to synchronize it with my online project.

Thank you very much for all your help on this problem.

There’s definitely something wrong with that but hopefully examining the JS code will clarify why the single quotes were needed.

It seems you are correct. Last week, I unfortunately only had time to quickly check my proposed solution to the problem. Because I was able to upload the experiment to Pavlovia and the instructions ran, I assumed the experiment worked. Unfortunately, upon further inspection, the experiment only runs until the end of the instructions. Randcond now gets treated as a string instead of a variable - as might be expected when using quotation marks - and thus the program is looking for a file named randcond.xlsx, which does not exist. So unfortunately, my problem is still not solved.