Closed MatusGasparik closed 2 years ago
Trying to run the examples in pythreejs/examples/Examples.ipynb:
from pythreejs import * import numpy as np from IPython.display import display from ipywidgets import HTML, Text, Output, VBox from traitlets import link, dlink ball = Mesh(geometry=SphereGeometry(radius=1, widthSegments=32, heightSegments=24), material=MeshLambertMaterial(color='red'), position=[2, 1, 0]) c = PerspectiveCamera(position=[0, 5, 5], up=[0, 1, 0], children=[DirectionalLight(color='white', position=[3, 5, 1], intensity=0.5)]) scene = Scene(children=[ball, c, AmbientLight(color='#777777')]) renderer = Renderer(camera=c, scene=scene, controls=[OrbitControls(controlling=c)]) display(renderer)
I get this error:
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) /var/folders/8_/89sz7q3961n_2p6drnympl1w0000gn/T/ipykernel_16692/4258969487.py in <module> 10 renderer = Renderer(camera=c, 11 scene=scene, ---> 12 controls=[OrbitControls(controlling=c)]) 13 display(renderer) ~/miniconda3/envs/sci39/lib/python3.9/site-packages/pythreejs/controls/OrbitControls_autogen.py in __init__(self, controlling, **kwargs) 27 def __init__(self, controlling=None, **kwargs): 28 kwargs['controlling'] = controlling ---> 29 super(OrbitControls, self).__init__(**kwargs) 30 31 _model_name = Unicode('OrbitControlsModel').tag(sync=True) ~/miniconda3/envs/sci39/lib/python3.9/site-packages/pythreejs/controls/Controls_autogen.py in __init__(self, **kwargs) 28 29 def __init__(self, **kwargs): ---> 30 super(Controls, self).__init__(**kwargs) 31 32 _model_name = Unicode('ControlsModel').tag(sync=True) ~/miniconda3/envs/sci39/lib/python3.9/site-packages/pythreejs/_base/Three.py in __init__(self, **kwargs) 15 16 def __init__(self, **kwargs): ---> 17 super(ThreeWidget, self).__init__(**kwargs) 18 self.on_msg(self._on_potential_ret_val) 19 ~/miniconda3/envs/sci39/lib/python3.9/site-packages/pythreejs/_example_helper.py in new_init(self, *args, **kwargs) 11 def new_init(self, *args, **kwargs): 12 kwargs['model_id'] = next(id_gen) ---> 13 old_init(self, *args, **kwargs) 14 Widget.__init__ = new_init ~/miniconda3/envs/sci39/lib/python3.9/site-packages/ipywidgets/widgets/widget.py in __init__(self, **kwargs) 413 414 Widget._call_widget_constructed(self) --> 415 self.open() 416 417 def __del__(self): ~/miniconda3/envs/sci39/lib/python3.9/site-packages/ipywidgets/widgets/widget.py in open(self) 436 args['comm_id'] = self._model_id 437 --> 438 self.comm = Comm(**args) 439 440 @observe('comm') ~/miniconda3/envs/sci39/lib/python3.9/site-packages/ipykernel/comm/comm.py in __init__(self, target_name, data, metadata, buffers, **kwargs) 55 if self.primary: 56 # I am primary, open my peer. ---> 57 self.open(data=data, metadata=metadata, buffers=buffers) 58 else: 59 self._closed = False ~/miniconda3/envs/sci39/lib/python3.9/site-packages/ipykernel/comm/comm.py in open(self, data, metadata, buffers) 89 comm_manager.register_comm(self) 90 try: ---> 91 self._publish_msg('comm_open', 92 data=data, metadata=metadata, buffers=buffers, 93 target_name=self.target_name, ~/miniconda3/envs/sci39/lib/python3.9/site-packages/ipykernel/comm/comm.py in _publish_msg(self, msg_type, data, metadata, buffers, **keys) 64 metadata = {} if metadata is None else metadata 65 content = json_clean(dict(data=data, comm_id=self.comm_id, **keys)) ---> 66 self.kernel.session.send(self.kernel.iopub_socket, msg_type, 67 content, 68 metadata=json_clean(metadata), ~/miniconda3/envs/sci39/lib/python3.9/site-packages/jupyter_client/session.py in send(self, stream, msg_or_type, content, parent, ident, buffers, track, header, metadata) 828 if self.adapt_version: 829 msg = adapt(msg, self.adapt_version) --> 830 to_send = self.serialize(msg, ident) 831 to_send.extend(buffers) 832 longest = max([len(s) for s in to_send]) ~/miniconda3/envs/sci39/lib/python3.9/site-packages/jupyter_client/session.py in serialize(self, msg, ident) 702 content = self.none 703 elif isinstance(content, dict): --> 704 content = self.pack(content) 705 elif isinstance(content, bytes): 706 # content is already packed, as in a relayed message ~/miniconda3/envs/sci39/lib/python3.9/site-packages/jupyter_client/session.py in json_packer(obj) 93 94 def json_packer(obj): ---> 95 return jsonapi.dumps( 96 obj, 97 default=json_default, ~/miniconda3/envs/sci39/lib/python3.9/site-packages/zmq/utils/jsonapi.py in dumps(o, **kwargs) 23 Keyword arguments are passed along to :py:func:`json.dumps`. 24 """ ---> 25 return json.dumps(o, **kwargs).encode("utf8") 26 27 ~/miniconda3/envs/sci39/lib/python3.9/json/__init__.py in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw) 232 if cls is None: 233 cls = JSONEncoder --> 234 return cls( 235 skipkeys=skipkeys, ensure_ascii=ensure_ascii, 236 check_circular=check_circular, allow_nan=allow_nan, indent=indent, ~/miniconda3/envs/sci39/lib/python3.9/json/encoder.py in encode(self, o) 197 # exceptions aren't as detailed. The list call should be roughly 198 # equivalent to the PySequence_Fast that ''.join() would do. --> 199 chunks = self.iterencode(o, _one_shot=True) 200 if not isinstance(chunks, (list, tuple)): 201 chunks = list(chunks) ~/miniconda3/envs/sci39/lib/python3.9/json/encoder.py in iterencode(self, o, _one_shot) 255 self.key_separator, self.item_separator, self.sort_keys, 256 self.skipkeys, _one_shot) --> 257 return _iterencode(o, 0) 258 259 def _make_iterencode(markers, _default, _encoder, _indent, _floatstr, ValueError: Out of range float values are not JSON compliant
This is the data that is passed to the JSONEncoder:
JSONEncoder
{'comm_id': 'pythree_example_model_245', 'data': {'buffer_paths': [], 'state': {'_model_module': 'jupyter-threejs', '_model_module_version': '^2.1.0', '_model_name': 'OrbitControlsModel', '_view_count': None, '_view_module': None, '_view_module_version': '', '_view_name': None, 'autoRotate': False, 'autoRotateSpeed': 2.0, 'controlling': 'IPY_MODEL_pythree_example_model_242', 'dampingFactor': 0.25, 'enableDamping': False, 'enableKeys': True, 'enablePan': True, 'enableRotate': True, 'enableZoom': True, 'enabled': True, 'keyPanSpeed': 7.0, 'maxAzimuthAngle': inf, 'maxDistance': inf, 'maxPolarAngle': 3.141592653589793, 'maxZoom': inf, 'minAzimuthAngle': -inf, 'minDistance': 0.0, 'minPolarAngle': 0.0, 'minZoom': 0.0, 'panSpeed': 1.0, 'rotateSpeed': 1.0, 'screenSpacePanning': True, 'target': (0.0, 0.0, 0.0), 'zoomSpeed': 1.0}}, 'target_module': None, 'target_name': 'jupyter.widget'}
Output from jupyter labextension list:
jupyter labextension list
JupyterLab v3.1.7 /Users/foo/miniconda3/share/jupyter/labextensions nbdime-jupyterlab v2.1.0 enabled OK @axlair/jupyterlab_vim v0.14.5 enabled OK (python, jupyterlab_vim) @jupyterlab/git v0.32.4 enabled OK (python, jupyterlab-git) @jupyter-widgets/jupyterlab-manager v3.0.1 enabled OK (python, jupyterlab_widgets) Other labextensions (built into JupyterLab) app dir: /Users/foo/miniconda3/share/jupyter/lab jupyter-threejs v2.3.0 enabled OK
Closing as duplicate of https://github.com/jupyter-widgets/pythreejs/issues/366
Trying to run the examples in pythreejs/examples/Examples.ipynb:
I get this error:
This is the data that is passed to the
JSONEncoder
:Versions info
Output from
jupyter labextension list
: