Open nvaytet opened 2 years ago
Interestingly, it works with 2.4.0
and ipywidgets=8.0.1
.
I get the same kind of failure with the parametric geometry example, even in 2.4.0, except mine is:
Failed to load model class 'RendererModel' from module 'jupyter-threejs'
makeError@http://localhost:8888/static/components/requirejs/require.js?v [...]
onScriptError@http://localhost:8888/static/components/requirejs/require.js?v [...]
I assume it is the same issue, you don't need any code to reproduce, just starting a new notebook. The browser console shows:
Failed to load extension: Array [ "nbextensions/jupyter-threejs/extension" ] Error: Automatic publicPath is not supported in this browser
The resource from “http://localhost:8888/nbextensions/widgets/notebook/js/extension.js?v=XXXX” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
This problem will definitely occur in both ubuntu and windows. Using Jupyter notebook will cause this problem, but not Jupyter lab.
Failed to load model class 'RendererModel' from module 'jupyter-threejs'
makeError@http://localhost:8888/static/components/requirejs/require.js?v [...]
onScriptError@http://localhost:8888/static/components/requirejs/require.js?v [...]
I'm not sure if Pythreejs supports Jupyter notebook, but I've tried many previous versions of Pythreejs and I've had issues similar to those associated with ‘RendererModel’.
What output do you see from jupyter nbextension list
? Is pythreejs in that list?
(if not see the Installation
section in the docs)
or for lab: jupyter labextension list
I don't know which of the commenters you are asking, but
What output do you see from
jupyter nbextension list
?
Known nbextensions:
config dir: /home/glisse/software/mambaforge/envs/py310/etc/jupyter/nbconfig
notebook section
jupyter-datawidgets/extension enabled
- Validating: OK
jupyter-matplotlib/extension enabled
- Validating: OK
jupyter-threejs/extension enabled
- Validating: OK
jupyterlab-plotly/extension enabled
- Validating: OK
jupytext/index enabled
- Validating: OK
jupyter-js-widgets/extension enabled
- Validating: OK
config dir: /home/glisse/.local/etc/jupyter/nbconfig
notebook section
jupyter-datawidgets/extension enabled
- Validating: OK
jupyter-matplotlib/extension enabled
- Validating: OK
jupyter-js-widgets/extension enabled
- Validating: OK
config dir: /etc/jupyter/nbconfig
notebook section
jupyter-js-widgets/extension enabled
- Validating: OK
vispy/extension enabled
- Validating: OK
Is pythreejs in that list?
There is jupyter-threejs (I would not get an error 'Failed to load extension: Array [ "nbextensions/jupyter-threejs/extension" ]' otherwise).
I am experiencing the same issue on Windows 11 and Ubuntu 22.04. Just tested with:
Notebooks extension list (pythreejs
widget not working)
Known nbextensions:
config dir: <redacted>\.venv\etc\jupyter\nbconfig
notebook section
jupyter-datawidgets/extension enabled
- Validating: ok
jupyter-threejs/extension enabled
- Validating: ok
jupyter-webrtc/extension enabled
- Validating: ok
jupyter-js-widgets/extension enabled
- Validating: ok
Jupyterlab extension list (pythreejs
widget working):
JupyterLab v3.6.1
<redacted>\.venv\share\jupyter\labextensions
jupyter-threejs v2.4.0 enabled ok (python, pythreejs)
jupyter-webrtc v0.6.0 enabled ok
jupyterlab-datawidgets v7.1.2 enabled ok
jupyterlab_pygments v0.2.2 enabled ok (python, jupyterlab_pygments)
@jupyter-widgets/jupyterlab-manager v5.0.5 enabled ok (python, jupyterlab_widgets)
Other labextensions (built into JupyterLab)
app dir: <redacted>\.venv\share\jupyter\lab
Note that the very first error showing in the Chrome dev console, as soon as the notebook is loaded and before any cell gets executed, is:
Failed to load extension: ['nbextensions/jupyter-threejs/extension'] Error: Automatic publicPath is not supported in this browser
at extension.js:1:846
at extension.js:1:988
at extension.js:1:999
at Object.execCb (require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:1693:33)
at Module.check (require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:876:55)
at Module.enable (require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:1173:22)
at Module.init (require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:786:26)
at callGetModule (require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:1200:63)
at Object.completeLoad (require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:1587:21)
at HTMLScriptElement.onScriptLoad (require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:1714:29)
This was pointed out in #395 and could be the root cause of this problem?
Note, if you have the error Automatic publicPath is not supported in this browser
, that is tracked in #395. That error is (AFAICT) different from what OP's issue is.
This public path thing should be fixed in 2.4.2 that I just pushed to PyPI. Please try it and see if it resolves this issue as well.
Wonderful, thank you! Just tested and 2.4.2
resolves the problem with classic notebooks as well for me.
Hmm, I don't seem to be able to reproduce my error anymore.
I tried making a new env with exactly the same versions as above, both using conda
and pip
, but I no longer get the javascript error.
I also tested pythreejs=2.4.2
and it also works fine.
I am not sure what the issue was in the first place, but if other people's issues have also gone away, then I would say you can go ahead and close this?
Thanks for the support!
I'm seeing similar javascript errors across several projects that depend on pythreejs.
I was trying to generate a pythreejs visualization with PyDy in both jupyter notebook and then jupyter lab and I get this error in both Firefox and Chromium:
This is with (conda forge packages):
I tried downgrading pythreejs and ipywidgets but still get the same error. You can also see that all visualizations in the PyDy documentation are now broken:
https://pydy.readthedocs.io/en/stable/examples/carvallo-whipple.html (very bottom should show a pythreejs window).
This example was built months ago and no longer displays, so this must be some change in a javascript library that is causing the issues. I haven't updated that page since it was working. The only thing that can change, I suppose, is that when you navigate to that page a javascript lib is downloaded that isn't pinned to a version that worked when it was built. I can even go back to a version of that page that was built like a year ago and it no longer works:
https://pydy.readthedocs.io/en/v0.7.1/examples/carvallo-whipple.html
My online book (and the pydy docs) generate pages using jupyter-sphinx and you can see a pythreejs example failing to load there too:
https://moorepants.github.io/learn-multibody-dynamics/visualization.html
This was build with pythreejs 2.3.0 which I pin in the CI builds. Seen here:
https://moorepants.github.io/learn-multibody-dynamics/install.html#software-versions
I've been unable to get pythreejs to display at all with any old versions (or the latest) in notebook or lab.
Related issues:
https://github.com/moorepants/learn-multibody-dynamics/issues/149
https://github.com/pydy/pydy/issues/493
Edit: I believe these errors have only appeared in the last week. I've been actively developing the book this past week and the animation was working within the last week on the Learn Multibody Dynamics web page.
This is with (conda forge packages):
Can you test if this also occurs with PyPI packages? If PyPI works, there might be something wrong with the conda-forge recipe.
I created a conda environment with:
name: bicycle-kickplate-model
channels:
- conda-forge
dependencies:
- setuptools
- cython
- gmpy2
- ipython <8.9 # annoying change to history and tab completion
- jupyter
- matplotlib
- mpmath
- notebook
- numpy
- scipy
# deps for pythreejs
- jupyterlab
- nodejs
- ipydatawidgets
- ipywidgets
- traitlets
I activated it and then installed pythreejs with python -m pip install pythreejs
:
Collecting pythreejs
Downloading pythreejs-2.4.2-py3-none-any.whl (3.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.4/3.4 MB 11.5 MB/s eta 0:00:00
Requirement already satisfied: ipywidgets>=7.2.1 in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from pythreejs) (8.0.5)
Requirement already satisfied: ipydatawidgets>=1.1.1 in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from pythreejs) (4.3.2)
Requirement already satisfied: numpy in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from pythreejs) (1.24.2)
Requirement already satisfied: traitlets in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from pythreejs) (5.9.0)
Requirement already satisfied: traittypes>=0.2.0 in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from ipydatawidgets>=1.1.1->pythreejs) (0.2.1)
Requirement already satisfied: ipython>=6.1.0 in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from ipywidgets>=7.2.1->pythreejs) (8.8.0)
Requirement already satisfied: widgetsnbextension~=4.0 in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from ipywidgets>=7.2.1->pythreejs) (4.0.6)
Requirement already satisfied: jupyterlab-widgets~=3.0 in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from ipywidgets>=7.2.1->pythreejs) (3.0.6)
Requirement already satisfied: backcall in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.2.0)
Requirement already satisfied: decorator in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (5.1.1)
Requirement already satisfied: jedi>=0.16 in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.18.2)
Requirement already satisfied: matplotlib-inline in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.1.6)
Requirement already satisfied: pickleshare in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.7.5)
Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.11 in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (3.0.38)
Requirement already satisfied: pygments>=2.4.0 in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (2.14.0)
Requirement already satisfied: stack-data in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.6.2)
Requirement already satisfied: pexpect>4.3 in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (4.8.0)
Requirement already satisfied: parso<0.9.0,>=0.8.0 in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from jedi>=0.16->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.8.3)
Requirement already satisfied: ptyprocess>=0.5 in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from pexpect>4.3->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.7.0)
Requirement already satisfied: wcwidth in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from prompt-toolkit<3.1.0,>=3.0.11->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.2.6)
Requirement already satisfied: executing>=1.2.0 in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from stack-data->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (1.2.0)
Requirement already satisfied: asttokens>=2.1.0 in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from stack-data->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (2.2.1)
Requirement already satisfied: pure-eval in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from stack-data->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.2.2)
Requirement already satisfied: six in /home/moorepants/miniconda/envs/bicycle-kickplate-model/lib/python3.11/site-packages (from asttokens>=2.1.0->stack-data->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (1.16.0)
Installing collected packages: pythreejs
Relevant conda list lines:
ipykernel 6.22.0 pyh210e3f2_0 conda-forge
ipython 8.8.0 pyh41d4057_0 conda-forge
ipython_genutils 0.2.0 py_1 conda-forge
ipywidgets 8.0.5 pyhd8ed1ab_0 conda-forge
jupyter 1.0.0 py311h38be061_8 conda-forge
jupyter_client 8.1.0 pyhd8ed1ab_0 conda-forge
jupyter_console 6.6.3 pyhd8ed1ab_0 conda-forge
jupyter_core 5.3.0 py311h38be061_0 conda-forge
jupyter_events 0.6.3 pyhd8ed1ab_0 conda-forge
jupyter_server 2.5.0 pyhd8ed1ab_0 conda-forge
jupyter_server_fileid 0.8.0 pyhd8ed1ab_0 conda-forge
jupyter_server_terminals 0.4.4 pyhd8ed1ab_1 conda-forge
jupyter_server_ydoc 0.8.0 pyhd8ed1ab_0 conda-forge
jupyter_ydoc 0.2.3 pyhd8ed1ab_0 conda-forge
jupyterlab 3.6.2 pyhd8ed1ab_0 conda-forge
jupyterlab_pygments 0.2.2 pyhd8ed1ab_0 conda-forge
jupyterlab_server 2.21.0 pyhd8ed1ab_0 conda-forge
jupyterlab_widgets 3.0.6 pyhd8ed1ab_0 conda-forge
nbclassic 0.5.3 pyhb4ecaf3_3 conda-forge
nbclient 0.7.2 pyhd8ed1ab_0 conda-forge
nbconvert 7.2.9 pyhd8ed1ab_0 conda-forge
nbconvert-core 7.2.9 pyhd8ed1ab_0 conda-forge
nbconvert-pandoc 7.2.9 pyhd8ed1ab_0 conda-forge
nbformat 5.8.0 pyhd8ed1ab_0 conda-forge
nodejs 18.15.0 h8d033a5_0 conda-forge
notebook 6.5.3 pyha770c72_0 conda-forge
notebook-shim 0.2.2 pyhd8ed1ab_0 conda-forge
pythreejs 2.4.2 pypi_0 pypi
I also want to point out again that the static web pages built even a year ago using a functioning set of conda forge packages for pythreejs no longer display the output. I haven't changed this page at all, for example:
https://pydy.readthedocs.io/en/v0.7.1/examples/carvallo-whipple.html
Yet, the display stopped working. The js console on that page displays:
Unhandled rejection serialize@https://cdn.jsdelivr.net/npm/@jupyter-widgets/html-manager@%5E1.0.1/dist/embed-amd.js:2:397067
5938/createModel/o<@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:841610
c@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:78248
6624/n/<[22]</t.exports/O.prototype._settlePromiseFromHandler@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:51172
6624/n/<[22]</t.exports/O.prototype._settlePromise@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:51972
6624/n/<[22]</t.exports/O.prototype._settlePromise0@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:52671
6624/n/<[22]</t.exports/O.prototype._settlePromises@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:54023
6624/n/<[22]</t.exports/O.prototype._fulfill@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:53041
6624/n/<[22]</t.exports/O.prototype._resolveCallback@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:49916
6624/n/<[22]</t.exports/O.prototype._settlePromiseFromHandler@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:51326
6624/n/<[22]</t.exports/O.prototype._settlePromise@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:51972
6624/n/<[22]</t.exports/O.prototype._settlePromise0@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:52671
6624/n/<[22]</t.exports/O.prototype._settlePromises@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:54023
6624/n/<[22]</t.exports/O.prototype._fulfill@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:53041
6624/n/<[23]</t.exports/s.prototype._resolve@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:57638
6624/n/<[23]</t.exports/s.prototype._promiseFulfilled@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:57979
6624/n/<[22]</t.exports/O.prototype._settlePromise@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:52073
6624/n/<[22]</t.exports/O.prototype._fulfillPromises@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:53546
6624/n/<[22]</t.exports/O.prototype._settlePromises@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:54075
l@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:5296
s@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:5236
6624/n/<[2]</a.prototype._drainQueues@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:6362
6624/n/<[2]</a/this.drainQueues@https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js:2:5169
I'm seeing this in the console on that page too:
The resource from “https://pydy.readthedocs.io/en/v0.7.1/examples/jupyter-threejs.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
[carvallo-whipple.html](https://pydy.readthedocs.io/en/v0.7.1/examples/carvallo-whipple.html)
Loading failed for the <script> with source “https://pydy.readthedocs.io/en/v0.7.1/examples/jupyter-threejs.js”. [all.min.css:1](webpack://./node_modules/@fortawesome/fontawesome-free/css/all.min.css)
Falling back to https://cdn.jsdelivr.net/npm/ for jupyter-threejs@^2.1.0 39 [embed-amd.js:26:40447](https://cdn.jsdelivr.net/npm/@jupyter-widgets/html-manager@%5E1.0.1/dist/embed-amd.js)
Referrer Policy: Ignoring the less restricted referrer policy “no-referrer-when-downgrade” for the cross-site request: https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js
I setup a more bare conda env with numpy, scipy, and sympy and then pip installed ipython, jupyter, pythreejs, notebook so that all jupyter related dependencies are pulled directly from PyPi. The same Javascript errors are present when running in Jupyter Notebook. I tried this notebook:
Interestingly the two meshes display but the Renderer throws the errors.
I tried pip installing pythrees==2.3.0 and then I get this slightly different error in the Jupyter Notebook:
In the Jupyter Notebook the JS console gives this error (pythreejs==2.4.0, ipywidgets==8.0.1 pip installed):
Error: Script error for "jupyter-threejs"
http://requirejs.org/docs/errors.html#scripterror
makeError http://localhost:8888/static/components/requirejs/require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:168
onScriptError http://localhost:8888/static/components/requirejs/require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:1735
[manager-base.js:575:20](webpack://jupyter-widgets/packages/base-manager/lib/manager-base.js)
Error: Script error for "jupyter-threejs"
http://requirejs.org/docs/errors.html#scripterror
makeError http://localhost:8888/static/components/requirejs/require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:168
onScriptError http://localhost:8888/static/components/requirejs/require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:1735
I pip installed the combo of dependency versions from https://github.com/jupyter-widgets/pythreejs/issues/395#issuecomment-1425765085, i.e. python -m pip install ipywidgets==7.7.2 jupyterlab_widgets==1.1.1 pythreejs==2.3.0 widgetsnbextension==3.6.1
and using Jupyter Notebook this notebook (https://moorepants.github.io/learn-multibody-dynamics/_downloads/4070c9f3ae1e94b53a42a781baf0509b/visualization.ipynb) now functions.
I noticed that our example in the thebe docs no longer works (it was also built some time ago): https://thebe.readthedocs.io/en/stable/examples/pythreejs-example.html
In the pythreejs docs (https://pythreejs.readthedocs.io/en/latest/examples/Animation.html) the renderer loads and the animations work. The console shows:
Loading failed for the <script> with source “https://pythreejs.readthedocs.io/en/latest/examples/jupyter-threejs.js”. [Animation.html:1:1](https://pythreejs.readthedocs.io/en/latest/examples/Animation.html)
Falling back to https://cdn.jsdelivr.net/npm/ for jupyter-threejs@^2.1.0 105 [embed-amd.js:26:40447](https://cdn.jsdelivr.net/npm/@jupyter-widgets/html-manager@%5E1.0.1/dist/embed-amd.js)
Referrer Policy: Ignoring the less restricted referrer policy “no-referrer-when-downgrade” for the cross-site request: https://cdn.jsdelivr.net/npm/jupyter-threejs@%5E2.1.0/dist/index.js
Edit: It seems to be loading the node package jupyter-threejs 2.1.0 which is some versions behind.
Are these enough clues to help me look further? I'm not that familiar with how the JS parts of this package might work, but I have an interested in getting all the websites I've mentioned working again.
In #389 they link to https://github.com/NVlabs/sionna/issues/106 which shows that a specific combinations of packages is needed to get 2.4.2 to work.
It looks like the problem is back after upgrading ipywidgets
(and more specifically jupyterlab-widgets 3.0.5 --> jupyterlab-widgets 3.0.6
).
This set of version is working:
ipydatawidgets==4.3.3
ipykernel==6.22.0
ipympl==0.9.3
ipython==8.13.1
ipywidgets==8.0.6
jupyter==1.0.0
jupyter-contrib-core==0.4.2
jupyter-contrib-nbextensions==0.7.0
jupyterlab==3.6.3
jupyterlab-widgets==3.0.5 # <-- intentionally downgrade to 3.0.5
notebook==6.5.4
pythreejs==2.4.2
traitlets==5.9.0
widgetsnbextension==4.0.7
But upgrading jupyterlab-widgets
to 3.0.6
or 3.0.7
breaks pythreejs
again (python -m pip install jupyterlab-widgets==3.0.6
). The error shown in the notebook is:
[Open Browser Console for more detailed log - Double click to close this message]
Model class 'RendererModel' from module 'jupyter-threejs' is loaded but can not be instantiated
TypeError: Cannot read properties of undefined (reading 'then')
at http://localhost:8888/lab/extensions/jupyter-threejs/static/jupyter-threejs-chunk.75bff6c5b3e16e2f7d65.js?v=75bff6c5b3e16e2f7d65:1:32057
at async Promise.all (index 20)
And in the console:
0.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1 Failed to fetch ipywidgets through the "jupyter.widget.control" comm channel, fallback to fetching individual model state. Reason: Control comm was closed too early
_loadFromKernel @ 150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1
134.c61b95b04e00f8487eeb.js?v=c61b95b04e00f8487eeb:1 Error: widget model not found
at f.get_model (150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1:3461)
at w.renderModel (134.c61b95b04e00f8487eeb.js?v=c61b95b04e00f8487eeb:1:72019)
renderModel @ 134.c61b95b04e00f8487eeb.js?v=c61b95b04e00f8487eeb:1
jlab_core.4d5114e25256eeddf4e4.js?v=4d5114e25256eeddf4e4:2 Connection lost, reconnecting in 0 seconds.
_reconnect @ jlab_core.4d5114e25256eeddf4e4.js?v=4d5114e25256eeddf4e4:2
150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1 Failed to fetch ipywidgets through the "jupyter.widget.control" comm channel, fallback to fetching individual model state. Reason: Control comm was closed too early
_loadFromKernel @ 150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1
595.7f2125f3d2c7376588c2.js?v=7f2125f3d2c7376588c2:1 Error serializing widget state attribute: camera
serialize @ 595.7f2125f3d2c7376588c2.js?v=7f2125f3d2c7376588c2:1
150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1 DOMException: Failed to execute 'structuredClone' on 'Window': #<Promise> could not be cloned.
at n.serialize (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/595.7f2125f3d2c7376588c2.js?v=7f2125f3d2c7376588c2:1:11092)
at n.<anonymous> (http://localhost:8888/lab/extensions/jupyter-threejs/static/jupyter-threejs-chunk.75bff6c5b3e16e2f7d65.js?v=75bff6c5b3e16e2f7d65:1:33930)
at n.u (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:74146)
at A._settlePromiseFromHandler (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:47082)
at A._settlePromise (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:47882)
at A._settlePromise0 (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:48581)
at A._settlePromises (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:49933)
at A._fulfill (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:48951)
at A._resolveCallback (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:45826)
at A._settlePromiseFromHandler (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:47236)
at A._settlePromise (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:47882)
at A._settlePromise0 (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:48581)
at A._settlePromises (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:49933)
at A._fulfill (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:48951)
at a._resolve (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:53548)
at a._promiseFulfilled (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:53889)
From previous event:
at A.B [as _captureStackTrace] (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:16275)
at A._then (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:42481)
at A.then (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:40837)
at l.initialize (http://localhost:8888/lab/extensions/jupyter-threejs/static/jupyter-threejs-chunk.75bff6c5b3e16e2f7d65.js?v=75bff6c5b3e16e2f7d65:1:16942)
at new e.Model (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/644.7d1bff49f8e38fac4070.js?v=7d1bff49f8e38fac4070:1:4062)
at new l (http://localhost:8888/lab/extensions/jupyter-threejs/static/jupyter-threejs-chunk.75bff6c5b3e16e2f7d65.js?v=75bff6c5b3e16e2f7d65:1:222174)
at f._make_model (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1:7962)
_make_model @ 150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1
150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1 TypeError: Cannot read properties of undefined (reading 'then')
at jupyter-threejs-chunk.75bff6c5b3e16e2f7d65.js?v=75bff6c5b3e16e2f7d65:1:32057
at async Promise.all (index 9)
at async f._make_model (150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1:7925)
_make_model @ 150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1
150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1 TypeError: Cannot read properties of undefined (reading 'then')
at http://localhost:8888/lab/extensions/jupyter-threejs/static/jupyter-threejs-chunk.75bff6c5b3e16e2f7d65.js?v=75bff6c5b3e16e2f7d65:1:32057
From previous event:
at A.B [as _captureStackTrace] (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:16275)
at http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:69410
at http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:69647
at a._iterate (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:53064)
at a.t [as _init] (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:52590)
at new a (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:52059)
at A.all (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:41924)
at Object.e [as deserialize] (http://localhost:8888/lab/extensions/jupyter-threejs/static/jupyter-threejs-chunk.75bff6c5b3e16e2f7d65.js?v=75bff6c5b3e16e2f7d65:1:31841)
at l._deserialize_state (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/595.7f2125f3d2c7376588c2.js?v=7f2125f3d2c7376588c2:1:12133)
at f._make_model (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1:7933)
_make_model @ 150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1
150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1 TypeError: Cannot read properties of undefined (reading 'then')
at jupyter-threejs-chunk.75bff6c5b3e16e2f7d65.js?v=75bff6c5b3e16e2f7d65:1:32057
at async Promise.all (index 20)
at async f._make_model (150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1:7925)
_make_model @ 150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1
2624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2 Unhandled rejection DataCloneError: Failed to execute 'structuredClone' on 'Window': #<Promise> could not be cloned. at n.serialize (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/595.7f2125f3d2c7376588c2.js?v=7f2125f3d2c7376588c2:1:11092) at n.<anonymous> (http://localhost:8888/lab/extensions/jupyter-threejs/static/jupyter-threejs-chunk.75bff6c5b3e16e2f7d65.js?v=75bff6c5b3e16e2f7d65:1:33930) at n.u (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:74146) at A._settlePromiseFromHandler (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:47082) at A._settlePromise (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:47882) at A._settlePromise0 (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:48581) at A._settlePromises (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:49933) at A._fulfill (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:48951) at A._resolveCallback (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:45826) at A._settlePromiseFromHandler (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:47236) at A._settlePromise (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:47882) at A._settlePromise0 (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:48581) at A._settlePromises (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:49933) at A._fulfill (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:48951) at a._resolve (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:53548) at a._promiseFulfilled (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:53889)From previous event: at A.B [as _captureStackTrace] (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:16275) at A._then (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:42481) at A.then (http://localhost:8888/lab/extensions/jupyter-threejs/static/624.12b52bd1c970e314e741.js?v=12b52bd1c970e314e741:2:40837) at l.initialize (http://localhost:8888/lab/extensions/jupyter-threejs/static/jupyter-threejs-chunk.75bff6c5b3e16e2f7d65.js?v=75bff6c5b3e16e2f7d65:1:16942) at new e.Model (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/644.7d1bff49f8e38fac4070.js?v=7d1bff49f8e38fac4070:1:4062) at new l (http://localhost:8888/lab/extensions/jupyter-threejs/static/jupyter-threejs-chunk.75bff6c5b3e16e2f7d65.js?v=75bff6c5b3e16e2f7d65:1:222174) at f._make_model (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1:7962)
This commit or this commit might be relevant, although I really don't know the details.
@bollwyvl might you have some insight on this issue? pythreejs is broken for me across all my websites and does not work in jupyter without very specific dependency pins.
My tests agree with MerlinND https://github.com/jupyter-widgets/pythreejs/issues/389#issuecomment-1532634461. For me, pythreejs works with jupyterlab-widgets=3.0.5
, but fails with jupyterlab-widgets=3.0.6
or 3.0.7
. (Other parameters such as browser and OS appear to be irrelevant.) I hope the developers of pythreejs and jupyterlab-widgets can work together to fix this!
jupyterlab-widgets=3.0.5 constrains me to use jupyterlab<=3.6.3. This is unfortunate, because I really like the collapsible-section functionality that is built right into jupyterlab=4.0.1 by default.
From the details reported by @merlinND https://github.com/jupyter-widgets/pythreejs/issues/389#issuecomment-1532634461, if the error started in jupyterlab-widgets 3.0.6, my bet is that this is a consequence of https://github.com/jupyter-widgets/ipywidgets/pull/3689. And it seems related to https://github.com/jupyter-widgets/ipywidgets/issues/3735.
I also noticed the same issue and pinned jupyterlab-widgets
.
Please let us know if anything could help to fix this!
I noticed today that the pythreejs visualizations on my website now work again, even though I have not updated anything on my side, for example: from https://moorepants.github.io/learn-multibody-dynamics/visualization.html#animated-interactive-3d-visualization
There was a ipwidgets release 2 days ago https://github.com/jupyter-widgets/ipywidgets/releases/tag/8.1.1 8.1.1 that reverts some PRs, but no idea if that is what fixed things.
This comment https://github.com/jupyter-widgets/ipywidgets/issues/3735#issuecomment-1591057532 says that the deserializer in the reverted PRs broke PyThreeJs https://github.com/jupyter-widgets/ipywidgets/issues/3735#issuecomment-1591057532
I also have a general question about this. It seems that our static websites (generated from jupyter notebooks + ipywidgets + pythreejs) can break if ipwidgets makes releases. The only reason I can think this occurs is if the static HTML has calls to download javascript from a CDN that is not pinned to a specific version. I would hope that if I post a static website, it wouldn't break if newer versions of the javascript packages are uploaded to npm, for example. Is this what is happening and, if so, shouldn't the javascript be pinned in the static HTML output?
I also have a general question about this. It seems that our static websites (generated from jupyter notebooks + ipywidgets + pythreejs) can break if ipwidgets makes releases. The only reason I can think this occurs is if the static HTML has calls to download javascript from a CDN that is not pinned to a specific version. I would hope that if I post a static website, it wouldn't break if newer versions of the javascript packages are uploaded to npm, for example. Is this what is happening and, if so, shouldn't the javascript be pinned in the static HTML output?
Yes, this problem is also present in Voila (or was before 0.5). I don't think we should do semver matching, or more strict semver matching (~ instead of ^). See also https://github.com/widgetti/ipyvue/issues/78#issuecomment-1708225921
Want to say that I am also facing the same problem as @moorepants , with the render call returning the javascript error saying it could not instantiate the class. I updated to the latest ipywidgets (8.1.1) and now things are working on jupyter-nbclassic. It doesn't work however on the new notebook (7), even though I seem to have the extension enabled.
When trying to render anything in a new conda env with version
2.4.1
, I get this Javascript error iconCode to reproduce:
The more detailed error after clicking:
Versions: