jupyter-widgets / pythreejs

A Jupyter - Three.js bridge
https://pythreejs.readthedocs.io
Other
934 stars 185 forks source link

Getting Error: No version of module jupyter-threejs is registered #396

Closed ghost closed 1 year ago

ghost commented 1 year ago

This is the code I am running

from pythreejs import *
import ipywidgets
from IPython.display import display

from pythreejs._example_helper import use_example_model_ids
use_example_model_ids()

view_width = 600
view_height = 400

sphere = Mesh(
    SphereBufferGeometry(1, 32, 16),
    MeshStandardMaterial(color='red')
)

cube = Mesh(
    BoxBufferGeometry(1, 1, 1),
    MeshPhysicalMaterial(color='green'),
    position=[2, 0, 4]
)

camera = PerspectiveCamera( position=[10, 6, 10], aspect=view_width/view_height)
key_light = DirectionalLight(position=[0, 10, 10])
ambient_light = AmbientLight()

scene = Scene(children = [sphere, cube, ambient_light, key_light], background=None)

renderer = Renderer(camera=camera,
                    scene=scene,
                    alpha=True,
                    clearOpacity=0,
                    controls=[OrbitControls(controlling=camera)])

display(renderer)

When I try to run that last line I get the error:

[Open Browser Console for more detailed log - Double click to close this message]
Failed to load model class 'RendererModel' from module 'jupyter-threejs'
Error: No version of module jupyter-threejs is registered
    at f.loadClass (http://localhost:59444/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.bcbea9feb6e7c4da7530.js?v=bcbea9feb6e7c4da7530:1:74856)
    at f.loadModelClass (http://localhost:59444/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.3e1e5adfd821b9b96340.js?v=3e1e5adfd821b9b96340:1:10729)
    at f._make_model (http://localhost:59444/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.3e1e5adfd821b9b96340.js?v=3e1e5adfd821b9b96340:1:7517)
    at f.new_model (http://localhost:59444/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.3e1e5adfd821b9b96340.js?v=3e1e5adfd821b9b96340:1:5137)
    at f.handle_comm_open (http://localhost:59444/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.3e1e5adfd821b9b96340.js?v=3e1e5adfd821b9b96340:1:3894)
    at _handleCommOpen (http://localhost:59444/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.bcbea9feb6e7c4da7530.js?v=bcbea9feb6e7c4da7530:1:73393)
    at b._handleCommOpen (http://localhost:59444/static/lab/jlab_core.c0430ccb496db993caa7.js?v=c0430ccb496db993caa7:2:1001250)
    at async b._handleMessage (http://localhost:59444/static/lab/jlab_core.c0430ccb496db993caa7.js?v=c0430ccb496db993caa7:2:1003240)

My JupyterLab version is 3.5.0 pythreejs version is 2.4.1 jupyter-threejs version is 2.4.0

vidartf commented 1 year ago

Which version of ipywidgets do you have installed?

vidartf commented 1 year ago

And what is the output of jupyter labextension list ?

merlinND commented 1 year ago

This sounds like the same problem as #389.

vidartf commented 1 year ago

Thanks. Closing as a duplicate of #389.