psychopy.org | Reference | Downloads | Github

PsychoPy v2021.1 local debug mode not working

I create a brand new experiment, click on the ‘Compile to JS script’ button, Send experiment to Runner, and click ‘Run PsychoJS task in local debug mode’.

The browser then displays: “initialising the experiment…” and the developer console lists errors such as the following:

Loading module from “http://localhost:12002/lib/core-2021.1.1.js” was blocked because of a disallowed MIME type (“text/html”).
Loading failed for the module with source “http://localhost:12002/lib/core-2021.1.1.js”.

The Runner created a new lib directory for the experiment, but the filenames in it don’t match the ones in the error messages (eg, core-2021.1.js vs core-2021.1.1.js), and all files in this directory contain this:

<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

This appears to be due to a bug in PsychoPy v2021.1, that can be fixed by editing the following PsychoPy code file: [python-package-directory]/psychopy/app/runner/runner.py:

@@ -703,7 +703,7 @@
         Useful for debugging, amending scripts.
         """
         libPath = str(self.currentFile.parent / self.outputPath / 'lib')
-        ver = '.'.join(self.app.version.split('.')[:2])
+        ver = '.'.join(self.app.version.split('.')[:3])
         psychoJSLibs = ['core', 'data', 'util', 'visual', 'sound']
 
         os.path.exists(libPath) or os.makedirs(libPath)

After making the patch, restarting PsychoPy, and removing any existing lib directory, local debug mode now works fine.

2 Likes

Nice fix, you could always make a PR for that fix on Github. See also Developers docs.

I’m in PsychoPy v2021.2 and local debug mode is not working for me. I’m getting exactly the same error message. So would be good to get some help!

Loading module from “http://localhost:12002/lib/psychojs-2021.2.0.js” was blocked because of a disallowed MIME type (“text/html”).
Loading failed for the module with source “http://localhost:12002/lib/psychojs-2021.2.0.js”.

  • I have checked the runner.py file, and it looks like the above patch has already been made in this version of PsychoPy, so I’m stumped.

Thanks in advance,
Jonathan

Hi @jonathan.david, thanks for flagging, we are hoping to have this fixed in the coming bugfix release, x

1 Like

Hi @jonathan.david, OK this should be fixed in the 2021.2.2 release, thanks again for your patience, x

2 Likes