jsmol broken on JupyterHub

114 views
Skip to first unread message

Christoph Ruegge

unread,
Jan 26, 2016, 10:44:33 AM1/26/16
to sage-devel
Hi.

I'm trying to get the jsmol applet running on JupyterHub. I'm using JupyterHub 0.3.0 (installed via pip) and Sage 6.10. The applet works nicely in a locally running Jupyter, but inside JupyterHub, it fails. I tried to "jupyter nbextension install" jsmol, without success.

I did some searching, and it seems as if the jsmol nbextension, in particular JSmol.min.js, is referenced via the path /nbextensions/jsmol from e.g. script tags, which is fine for Jupyter, but for JupyterHub probably needs to be prefixed with /user/$USER. Most requests under / apparently get redirected to /hub, where the JupyterHub API resides, but not the nbextensions. There is an option path_to_jsmol in the JSMolHtml class which might be used for this purpose, but it is apparently not properly set from backend_ipython.py.

I would be grateful for any advice.

Volker Braun

unread,
Jan 26, 2016, 10:47:58 AM1/26/16
to sage-devel
It doesn't work right now; The kernel doesn't know whether it is running under jupyter or jupyterhub.

Kwankyu Lee

unread,
Feb 20, 2018, 7:57:39 PM2/20/18
to sage-devel


On Wednesday, January 27, 2016 at 12:47:58 AM UTC+9, Volker Braun wrote:
It doesn't work right now; The kernel doesn't know whether it is running under jupyter or jupyterhub.

After lots of trial and errors, I managed to make sagemath work under Jupyterhub. One cause of constant confusion was that these jsmol, threejs, mathjax are served at /nbextensions. These are not proper nbextensions in Jupyter notebook ecosystem, but just static files. I suppose the proper place to serve them is /static, like /static/jsmol, .... 

Fortunately we can use a Jupyter notebook option to serve /static from arbitrary directory that contains jsmol, threejs, and mathjax:

c.NotebookApp.extra_static_paths = ["/path/to/extra/static/files"]

I guess that with some changes mainly replacing "/nbextensions" to "/static",  sage 3d and interact outputs all would work fine. 

Jupyterhub serves static files at /hub/static, so it would be necessary to forward(alias) /static to /hub/static for sage 3d and interact outputs to work. 

Reply all
Reply to author
Forward
0 new messages