Closed francesco-ballarin closed 9 months ago
Hi, as @francesco-ballarin, I have issue when trying to use pythreejs
in colab as pyvista
backend. The issue is probably related to the one reported above. Do you have any update?
I can reproduce the above error on my local JupyterLab installation on Ubuntu 22.04, no connection to Google Colab. I initially encountered this error using pythreejs via PyVista.
Versions (not sure which ones are most important):
Thanks @hakonanes , so it seems that the issue may affect jupyterlab installations as well. After 3 months, it would be nice to have a comment or suggestion from pythreejs develoeprs.
The problem is not specific to DirectionalLight
, SpotLight
has the same problem.
I also got this error on my local macOS, after upgrading my packages.
Now, I could find a temporary fix. When downgrading traitlets from latest 5.8.0 to 4.3.3, the error disappeared.
For that I wrote the environment.yml
file and created a conda environment:
conda env create --file environment.yml
environment.yml:
name: pjs
channels:
- conda-forge
dependencies:
- python=3.9
- jupyterlab
- pythreejs
- pyvista
- traitlets=4.3.3
By removing the last line, the above mentioned error appears again.
P.S. Strangely pythreejs
worked with traitlets v5.7.1 before, so I am wondering why this problem occurs
Thanks @kazumamatata for the report and the workaround on macOS.
In terms of the original bug report (on Colab), I want to point out for pythreejs
developers that
traitlets
were released at the time of the original bug report (the latest released version in September 2022 was v5.4.0)traitlets
does not seem feasible on Colab, since it requires to force a kernel restart (due to being imported on startup, I guess)I did a bit of troubleshooting on this, and noted the following:
pythreejs
with recent version of everything. No other packages / envs are important in order to repro the current error.I install jupyterlab-kernelspy to inspect the comm messages, and found this error occurs when the default "target" for a DirectionalLight
is created from the kernel side:
Exception opening comm with target: jupyter.widget
Traceback (most recent call last):
File "<env root>lib\site-packages\comm\base_comm.py", line 237, in comm_open f(comm, msg)
File "<env root>lib\site-packages\ipywidgets\widgets\widget.py", line 427, in handle_comm_opened widget = widget_class(comm=comm)
File "<env root>lib\site-packages\pythreejs\core\Object3D_autogen.py", line 26, in __init__ super(Object3D, self).__init__(**kwargs)
File "<env root>lib\site-packages\pythreejs\_base\Three.py", line 17, in __init__ super(ThreeWidget, self).__init__(**kwargs)
File "<env root>lib\site-packages\ipywidgets\widgets\widget.py", line 502, in __init__ super().__init__(**kwargs)
File "<env root>lib\site-packages\traitlets\traitlets.py", line 1346, in __init__ setattr(self, key, value)
File "<env root>lib\site-packages\traitlets\traitlets.py", line 732, in __set__ self.set(obj, value)
File "<env root>lib\site-packages\traitlets\traitlets.py", line 706, in set new_value = self._validate(obj, value)
File "<env root>lib\site-packages\traitlets\traitlets.py", line 738, in _validate value = self.validate(obj, value)
File "<env root>lib\site-packages\traitlets\traitlets.py", line 2150, in validate self.error(obj, value)
File "<env root>lib\site-packages\traitlets\traitlets.py", line 844, in error
raise TraitError(e) traitlets.traitlets.TraitError: The 'comm' trait of an Object3D instance expected a Comm or None, not the BaseComm at '0x13ea2217df0'.
DirectionalLight
fails after that, since it is referencing a widget that failed to create.comm_open
message is not shown in the log viewer in lab. This should ideally be added in Lab.It might also be an issue in the new comm
package (cc @martinRenou ).
Ah, I had ipykernel 6.19.4, which has been pulled from PyPI, but is still up on conda-forge... Downgrading to ipykernel 6.16.2 seems to have fixed the issue for me locally. I'm guessing that downgrading to traitlets 4 indirectly fixed it by constraining which version of ipykernel that you could have, since it currently depends on traitlets>=5.4.0. If someone can repro this error with ipykernel<=6.16.2
, please add some detailed repro steps, and I can look again.
If someone can repro this error with ipykernel<=6.16.2
Colab is quite a lot behind current releases, and therefore definitely satisfies that condition. See https://github.com/googlecolab/backend-info/blob/2cec3e7ca1ae121133d9f8ee350e2aebf4518293/pip-freeze.txt#L163
To troubleshoot colab issues, I suggest you reach out to colab :)
Done that, https://github.com/googlecolab/colabtools/issues/3159 ;)
My main motivation was using pythreejs
within pyvista
. Since the pythreejs
backend was removed from pyvista
in https://github.com/pyvista/pyvista/pull/4687, I don't have any further interest in this, hence I am closing this. Feel free to reopen if someone else is interested in this for pythreejs
on its own, rather than within pyvista
.
Hi, I am trying to use pythreejs on Google Colab, and I am seeing a failure related to
DirectionalLight
.A minimal notebook to reproduce has the following content:
Cell 4 runs correctly, the box shows up and the user can interact with it. Cell 5 runs, a black background gets rendered, but immediately below the black widget there are several instances of
I suspect that some of
pythreejs
dependencies already pre-installed on Colab are quite old, and by runningpip install --upgrade
on the right dependency the error would disappear. Unfortunately, I can't pinpoint which dependency I should upgrade. Can you help me with that?The only dependency I am confident one must not upgrade is
ipywidgets
: it seems that doing so would make Cell 2 ineffective, and Cell 2 is fundamental for the widget in Cell 4 to correctly show up.The same notebook, and much more complicated ones, run correctly on my local jupyter lab installation.