Description of the problem:
Keep getting the unknown resources errors when sync the program.
All attempts to solve this issue:
set HTML folder as path when sync online. This results in the js file and index file showing up in the folder and a resources folder created and stimuli.xlsx showing up there. Not working.
sync and create js file (with the index.html) in the same folder as the .psyexp file. The stimuli.xlsx is in the same folder as the js file. Not working.
Mannually create /html/resources folder and put the excel file under this folder. the js file (with index) is still with psyexp file. Not working.
In the stimuli import code component, the import path is relative path, only stimuli.xlsx.
Any idea what happened here?
However I am still waiting for Becca’s reply regarding how exactly the .js file identifies the data source and loads it to the program. I am confused why the stimuli is not added to the resource. My stimuli.xlsx already present at the same folder as the .js file why the psychopy cannot add it to the resource dictionary automatically?
Thanks for the explanation. If this is the case, how I should explicitly declare the file path in a “user code” mode? It seems that I cannot access the psychoJS.start(resoures: {}) using the code component within the builder.
To clarify - was the stimuli.xlsx listed in the experiment settings > online tab in the resources list? that is what populated this part of the code. I recommend using that to add resources rather than manually editing code.
Depending what version of PsychoPy you are using, one reason a resource might not beginning resources are not automatically added when a resource is indexed from inside another resource (e.g. you have nested loops and the excel file that lists other excel files).
Thanks for your reply. I add the stimuli.xlsx to the additional resource place and this file shows up in the psychoJS.start(resources: {}) and it works.
I do have another question about “unknown resources” issue. I have another project that uses sound components. The path to sound files are saved in the excel files column “savepath” but the .js file cannot find the resource. (p.s. the excel file has been added to the resources and this runs successfully in local debug mode).
Here is the link to the project. The excel file named “sentence_processed.xlsx”
Looking at your .psyexp file I can this is because the file is not listed in the experiment settings > online > resources tab. Add all of the required resources in this additional resources space
Great thanks! It is fixed. So it seems that the path saved within the .xlsx files will not be reached by the server if the these files is imported through the code while such file-saved paths work for the cases where the .xlsx file is added through builder right?
For those using code component should also add the multi-media resources to the additional resources.
Just a summary after several posts and big thanks to @Becca. When handling the unknown resources error
Add all required sources to the additional resources within the experiment settings → online tab. If only using the builder, the builder will automatically do this for you. However, when the stimuli file is imported through customized code components, this is needed because the .js file seems not to be able to handle the imported file through js variables such as var a = 'certain path' (here thanks to @wakecarter). What this step does as a form of js code is basically to inform where to find the resources in
psychoJS.start({
expName: expName,
expInfo: expInfo,
resources: [,
# here is the place to add the stimuli, and other required files such as
{'name': 'image/imagedemo1.png', 'path': 'image/imagedemo1.png'},
{'name': 'stimuli.xlsx', 'path': 'stimuli.xlsx'}
]
});
This is also needed when multi-media files, such as image, sound files are included in the experiment and the path is indicated or saved within the stimuli.xlsx file. Add those files to the additional resources.
There is no need to export .js files to HTML when synthesizing the project online. Just leave the output path blank. The server will find resources in the folder where the .js file sits.
I’m posting this for the benefit of other relative newbies like me who might be googling madly for a solution using a more recent version of PsychoPy. I’m a rank beginner with online experiments and so some of my suggestions might be a bit “magical”. But after repeatedly encountering an “unknown resource error” using PsychoPy version 2021.2.2 (Mac Catalina 10.15.7) – even after following the instructions here to ensure resources were listed under the experiment settings online tab – I finally found other online resources to lead me to a solution that I hope others might also find helpful. None of this is my own work – it is helpful advice provided by others in up-to-date resources that I hadn’t known existed!
Download the most recent version of PsychoPy if that is not what you are already working with
Make a note of the latest version of PsychoPy with which the PsychoPyPolyfill is compatible (currently 2021.1.4)
In PsychoPy Experiment Settings (the gear icon) > Basic > set “use PsychoPy version” to match the latest supported version (e.g., 2021.1.4)
In PsychoPy Experiment Settings (the gear icon) > Online make sure you add all resources that are needed by your experiment (e.g., .xlsx, .csv etc), ensuring that the path you use matches the path you use in your Designer call
In PsychoPy Experiment Settings (the gear icon) > Online set the output path to html
File > Export HTML
From within PsychoPy: Pavlovia > [New or Sync]
14. Just to be sure the sync works, you can also select the blue globe icon with the “P” from the top of the PsychoPy window and select your Pavlovia experiment name, ensure that the local is correct, then sync (this is also probably a bit of magical thinking but I find this more reliable than the step outlined in “13”, above)
Following these steps eliminated a persistent “unknown resource error” as well as an occasional error of getting stuck on experiment initialization due to failure to find a tone file.
This solved the problem for me as well! I deleted and re-added all resources from experiment settings, committed the changes with Sublime Merge, and then the task was able to find the missing excel file!