Inititilising hang with JS error

PsychoPy version (e.g. 2024.2.4 Py 3.8):
2024.2.4 (experiment was designed in older version, now want to include surveys eventually)

Standard Standalone Installation? (y/n)
y
URL of experiment:

Do you want it to also run locally? (y/n)
n
What are you trying to achieve?:
Run online

What did you try to make it work?:
Developer tools shows an error in JS code


The code is here and appears to be accurate

I deleted everything except the psyexp and uploaded again and received the same error.
I changed the java code manually to this:

and received an error for “*”, so I changed it back to Auto->JS.
I removed an online output set to “html” in error

After all these, it still runs locally, but not online (including incognito).

Link to the most relevant existing thread you have found:

What specifically went wrong when you tried that?:
“Uncaught SyntaxError: Unexpected token ‘{’ (at PVT.js:121:10)” from developer tools.

I think your unexpected token is * not {

Yes, the output path is blank.
The original error was a “{”, but it was to import “core”. I believe core is imported automatically now, so I deleted that code. It still runs locally.

We are working in builder, but from someone’s previously published experiment. I am using code to find where to go in Builder.

I’m wondering if this is an issue throughout, because now I’m getting this Developer Tools error

with this builder code

This also may be a different/related issue you mentioned in a previous post:

I see your crib notes say never import

I’m sure there is some way to still use time, random, and similar, no?

I remove the import for random:
import random
That error was eliminated. Now this error remains:

Failed to load resource: the server responded with a status of 404 () pvtexample/lib/psychojs-2024.2.4.css:1

This appears to be written to the .js automatically when no version is specified:

Rolling back to an earlier version of PsychoPy here:


Creates fatal errors locally

Traceback (most recent call last):
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/app/builder/builder.py”, line 1389, in runFile
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/app/runner/runner.py”, line 642, in runLocal
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/scripts/psyexpCompile.py”, line 78, in generateScript
psychopy.scripts.psyexpCompile.LegacyScriptError: Error: Script compile exited with code 1. Traceback:
2025-03-12 11:10:35.223 python[43424:13188610] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/zf/0m0fm2gj4jv2dq4738ym08600000gn/T/org.opensciencetools.psychopy.savedState
Traceback (most recent call last):
File “runpy.pyc”, line 196, in _run_module_as_main
File “runpy.pyc”, line 86, in _run_code
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/scripts/psyexpCompile.py”, line 229, in
compileScript(args.infile, args.version, args.outfile)
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/scripts/psyexpCompile.py”, line 219, in compileScript
thisExp = _getExperiment(infile, version)
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/scripts/psyexpCompile.py”, line 146, in _getExperiment
from psychopy.app.builder import experiment
File “/Users/mycomputer/.psychopy3/versions/psychopy/app/builder/init.py”, line 5, in
from .builder import BuilderFrame
File “/Users/mycomputer/.psychopy3/versions/psychopy/app/builder/builder.py”, line 59, in
from .dialogs import (DlgComponentProperties, DlgExperimentProperties,
File “/Users/mycomputer/.psychopy3/versions/psychopy/app/builder/dialogs/init.py”, line 29, in
from .dlgsCode import DlgCodeComponentProperties, CodeBox
File “/Users/mycomputer/.psychopy3/versions/psychopy/app/builder/dialogs/dlgsCode.py”, line 25, in
from psychopy.app.coder.codeEditorBase import BaseCodeEditor
File “/Users/mycomputer/.psychopy3/versions/psychopy/app/coder/init.py”, line 8, in
from .coder import CoderFrame, BaseCodeEditor # pylint: disable=W0401
File “/Users/mycomputer/.psychopy3/versions/psychopy/app/coder/coder.py”, line 47, in
from psychopy.app.coder.fileBrowser import FileBrowserPanel
File “/Users/mycomputer/.psychopy3/versions/psychopy/app/coder/fileBrowser.py”, line 21, in
import imghdr
ModuleNotFoundError: No module named ‘imghdr’

These all appear to be related, as the line that defines the library pull/location also is not found at launch time?

Have you got a local lib folder (you shouldn’t have one)?

no, got me confused too :slight_smile:

I’ve just noticed. Use PsychoPy version should be blank. There might be a mismatch between the version in index.htnl and the version Pavlovia thinks you want. Turn ro inactive then back to piloting.

I thought that might be it too and had tried with it blank. I just tried again (verified below).

I still get this (launched incognito after deleting existing files ancillary to psyexp)

I’m not sure where/why it keeps looking for this. I’m looking through code for mayb reliance on a library that would not be loaded online.

Maybe it is specified online here and I cannot change it?

I saw the directions to never delete the files from the server in testing, so I’ve been avoiding that. Maybe I need to in this case?

Please could you add me (Wake) as a developer and I’ll take a look.

1 Like

Invited.

For followers, sending Wake an invitation as a developer required going to “View code” in Pavlovia. This took me to my GitHub project. The left panel has “Members” tab. There, I set permissions and sent the invitation to Wake.

Are you sure you’ve done this? If I fork your project I get the next error.

No, I thought “set to pilot” referred to this in builder!

I reset the experiment on Pavlovia to “Pilot” mode and back to “Running” and now get that same error you posted.

I fixed the error by replacing core.getTime with this:

my_clock = core.Clock()

def setup_random_duration():
    # Use the Clock instance to get the time
    return (my_clock.getTime() % 1) * (max_val - min_val) + min_val

We are now running!

In hindsight, I’m not sure these script changes were necessary, but they do remove reliance on an additional library, if that is desirable.

1 Like