Keep getting unknown resource errors

URL of experiment: Sign in · GitLab

Description of the problem:
Keep getting the unknown resources errors when sync the program.
unknown resources issue

All attempts to solve this issue:

  1. 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.
  2. 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.
  3. 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?



no idea yet, but the link to your project leads to a Not found page

Best wishes Jens

Thanks for the help. Sorry i didn’t realize the access issue of the project. New updates below.

Just a follow up post. The solution is manually adding {'name': 'stimuli.xlsx', 'path': 'stimuli.xlsx'} to the resource dictionary in .js file where

  expName: expName,
  expInfo: expInfo,
  resources: [
    {'name': 'image/imagedemo2.png', 'path': 'image/imagedemo2.png'},
    {'name': 'instrucitonimage.xlsx', 'path': 'instrucitonimage.xlsx'},
    {'name': 'image/imagedemo4.png', 'path': 'image/imagedemo4.png'},
    {'name': 'image/imagedemo3.png', 'path': 'image/imagedemo3.png'},
    {'name': 'image/imagedemo1.png', 'path': 'image/imagedemo1.png'}

I didn’t output the files to an HTML folder, as suggested by the psychopy developer, see the post here PsychoPy Builder not creating HTML folder.

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 in advance.

This explanation may help.

1 Like

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.

Hi There,

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).


Hi Becca,

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”

Hi there,

It looks like that resource isn’t in the list of loaded resources in the .js file

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 :slight_smile:

1 Like

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

  1. 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
  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'}
  1. 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.
  2. 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.

WoW!!! You help me again. Thanks,Becca!

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!

  1. Download the most recent version of PsychoPy if that is not what you are already working with

  2. Go to: PsychoPy Python to Javascript crib sheet 2021 - Google Docs

This is the latest ‘crib sheet’ compatible with most recent PsychoPy versions, authored by Wakefield Morys-Carter (thank you!!!)

  1. Within that document, you’ll see instructions to follow this link: Thomas Pronk / demo_polyfill · GitLab

  2. From here, download the most recent version of PsychoPolyfill.js to the same folder where you have your PsychyoPy script

  3. Then

Add a code component called code_JS in your experiment’s first routine.
Switch it from Auto->JS to JS

  1. From within code_JS > * BEFORE * Experiment tab paste exactly this, including the final semicolon:

import PsychoPolyFill from ‘./PsychoPolyfill.js’;

  1. From within code_JS > * BEGIN * Experiment tab paste exactly this, including the final semicolon:

PsychoPolyFill(expInfo.psychopyVersion, psychoJS, util);

  1. Make a note of the latest version of PsychoPy with which the PsychoPyPolyfill is compatible (currently 2021.1.4)

  2. In PsychoPy Experiment Settings (the gear icon) > Basic > set “use PsychoPy version” to match the latest supported version (e.g., 2021.1.4)

  3. 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

  4. In PsychoPy Experiment Settings (the gear icon) > Online set the output path to html

  5. File > Export HTML

  6. 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.